diff --git a/LuaLibs/ProcessLapJoint.lua b/LuaLibs/ProcessLapJoint.lua index 8f5ae63..2504525 100644 --- a/LuaLibs/ProcessLapJoint.lua +++ b/LuaLibs/ProcessLapJoint.lua @@ -237,6 +237,63 @@ local function InitGlob( Proc, nPhase, nRawId, nPartId, dOvmHead) return true, '' end +--------------------------------------------------------------------- +local function UpdateFacet1Data( nProcId, FData, nFacInd, dFacElev) + if not FData then return nil end + FData.nFacInd = nFacInd + if dFacElev then + FData.dFacElev = dFacElev + end + if FData.nFacInd and FData.nFacInd > -1 then + FData.ptC, FData.vtN = EgtSurfTmFacetCenter( nProcId, FData.nFacInd, GDB_ID.ROOT) + FData.rfFac, FData.dH, FData.dV = EgtSurfTmFacetMinAreaRectangle( nProcId, FData.nFacInd, GDB_ID.ROOT) + end + return FData +end + +--------------------------------------------------------------------- +local function UpdateFacet2Data( nProcId, FData, nFacInd2, dFacElev2) + if not FData then return nil end + FData.nFacInd2 = nFacInd2 + if dFacElev2 then + FData.dFacElev2 = dFacElev2 + end + if FData.nFacInd2 and FData.nFacInd2 ~= true and FData.nFacInd2 > -1 then + FData.ptC2, FData.vtN2 = EgtSurfTmFacetCenter( nProcId, FData.nFacInd2, GDB_ID.ROOT) + FData.rfFac2, FData.dH2, FData.dV2 = EgtSurfTmFacetMinAreaRectangle( nProcId, FData.nFacInd2, GDB_ID.ROOT) + end + return FData +end + +--------------------------------------------------------------------- +local function GetFacetsData( nProcId, bIs3Faces) + local FData = {} + local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( nProcId, _nPartId, bIs3Faces) + + if nFacInd then + FData = UpdateFacet1Data( nProcId, FData, nFacInd, dFacElev) + FData = UpdateFacet2Data( nProcId, FData, nFacInd2, dFacElev2) + if FData.nFacInd == -1 and FData.nFacInd2 and FData.nFacInd2 == true then + FData.isOrthoFaces = true + end + end + return FData +end + +--------------------------------------------------------------------- +local function SwapFacetsData( FData) + if FData then + FData.nFacInd, FData.nFacInd2 = FData.nFacInd2, FData.nFacInd + FData.dFacElev, FData.dFacElev2 = FData.dFacElev2, FData.dFacElev + FData.ptC, FData.ptC2 = FData.ptC2, FData.ptC + FData.vtN, FData.vtN2 = FData.vtN2, FData.vtN + FData.rfFac, FData.rfFac2 = FData.rfFac2, FData.rfFac + FData.dH, FData.dH2 = FData.dH2, FData.dH + FData.dV, FData.dV2 = FData.dV2, FData.dV + end + return FData +end + --------------------------------------------------------------------- local function GetToolInfoForMachining( sMachiningName) if EgtMdbSetCurrMachining( sMachiningName) then @@ -680,10 +737,9 @@ function ProcessLapJoint.IsHeadFeature( Proc, b3Raw, dCurrOvmH) return false end end + local FData = GetFacetsData( Proc.Id) -- deve avere la normale principale diretta verso la testa - local nFacInd, _ = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - if vtN and vtN:getX() < 0.499 then + if FData.vtN and FData.vtN:getX() < 0.499 then return false elseif Proc.Fct >= 5 then return true @@ -732,14 +788,12 @@ function ProcessLapJoint.IsTailFeature( Proc, b3Raw) return false end end + local FData = GetFacetsData( Proc.Id) -- deve avere la normale principale diretta verso la coda (oppure tunnel) - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - if vtN and vtN:getZ() < BD.NZ_MINA and nFacInd2 then - _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) - dElev = dElev2 + if FData.vtN and FData.vtN:getZ() < BD.NZ_MINA and FData.nFacInd2 then + FData = SwapFacetsData( FData) end - if not vtN or vtN:getX() > -0.001 or dEndDist + vtN:getX() * dElev > 0 then + if not FData.vtN or FData.vtN:getX() > -0.001 or dEndDist + FData.vtN:getX() * FData.dFacElev > 0 then return false else return true @@ -752,6 +806,7 @@ function ProcessLapJoint.Classify( Proc, b3Raw) if not InitGlob( Proc) then return false end + -- se 1 faccia if Proc.Fct == 1 then -- dati della faccia @@ -778,11 +833,10 @@ function ProcessLapJoint.Classify( Proc, b3Raw) else local bClosedOrthoFaces local nDeletedFace - -- recupero la faccia con il maggior numero di adiacenze e minor elevazione - local nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - if not nFacInd or nFacInd < 0 then - if nFacInd == -1 then - bClosedOrthoFaces = nFacInd2 + local FData = GetFacetsData( Proc.Id) + if not FData.nFacInd or FData.nFacInd < 0 then + if FData.nFacInd == -1 then + bClosedOrthoFaces = FData.isOrthoFaces --nFacInd2 else return false end @@ -796,10 +850,10 @@ function ProcessLapJoint.Classify( Proc, b3Raw) nDeletedFace = i - 1 if EgtSurfTmRemoveFacet( nNewProc, nDeletedFace) then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - nFacInd, dElev, nFacInd2, dElev2 = BL.GetFaceWithMostAdj( nNewProc, _nPartId) - if not nFacInd or nFacInd < 0 then - if nFacInd == -1 then - bClosedOrthoFaces = nFacInd2 + FData = GetFacetsData( nNewProc) + if not FData.nFacInd or FData.nFacInd < 0 then + if FData.nFacInd == -1 then + bClosedOrthoFaces = FData.isOrthoFaces -- nFacInd2 EgtErase( nNewProc) break else @@ -815,10 +869,9 @@ function ProcessLapJoint.Classify( Proc, b3Raw) end -- se riconosciuta fessura ricalcolo l'elevazione dalla faccia di fondo if bClosedOrthoFaces then - nFacInd = nDeletedFace + FData = UpdateFacet1Data( Proc.Id, FData, nDeletedFace) -- rendo nulla la faccia opzionale perchè si tratta di una fessura - nFacInd2 = nil - dElev = BL.GetFaceElevation( Proc.Id, nFacInd) + FData = UpdateFacet2Data( Proc.Id, FData, nil) bClosedOrthoFaces = false -- non lo setto come tunnel end end @@ -836,27 +889,26 @@ function ProcessLapJoint.Classify( Proc, b3Raw) return false end else - local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se può essere fatto con utensile tipo lama local bUseBHSideMill, _, _, dMaxMat = VerifyBHSideMill( Proc) -- if bUseBHSideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then - if bUseBHSideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then + if bUseBHSideMill and ( dMaxMat <= FData.dH + 15 * GEO.EPS_SMALL) then return true, false -- altrimenti controllo se deve essere ruotato con le altre lavorazioni else -- dati della faccia - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) + local _, vtN = EgtSurfTmFacetCenter( Proc.Id, FData.nFacInd, GDB_ID.ROOT) -- cerco se c'è faccia adiacente sul lato più lungo - local nFaceAdj = GetFaceAdj( Proc, nFacInd, dH, dV) or -1 + local nFaceAdj = GetFaceAdj( Proc, FData.nFacInd, FData.dH, FData.dV) or -1 local _, bIsL = TestUL( Proc) -- verifico se è lavorabile solo dal basso local bDown = ( vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD) -- se verso il basso, verifico se utilizzabile seconda faccia if bDown then - if nFacInd2 and dElev2 < 2 * dElev then - local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) + if FData.nFacInd2 and FData.dFacElev2 < 2 * FData.dFacElev then + local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, FData.nFacInd2, GDB_ID.ROOT) bDown = ( vtN2:getZ() < BD.NZ_MINB) - elseif not nFacInd2 and bIsL and nFaceAdj >= 0 then + elseif not FData.nFacInd2 and bIsL and nFaceAdj >= 0 then local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFaceAdj, GDB_ID.ROOT) bDown = ( vtN2:getZ() < BD.NZ_MINB) end @@ -1109,9 +1161,9 @@ local function MakePreCuts( Proc) end --------------------------------------------------------------------- -local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpecialApp, sMillMaster, nFacInd2, dFacElev2) +local function MakeByMill( Proc, FData, dCollSic, bSpecialApp, sMillMaster) -- Cerco una faccia adiacente alla principale sul lato lungo - local nFacAdj, sErr = GetFaceAdj( Proc, nFacInd, dH, dV) + local nFacAdj, sErr = GetFaceAdj( Proc, FData.nFacInd, FData.dH, FData.dV) if nFacAdj < 0 then EgtOutLog( sErr) return false, sErr @@ -1128,16 +1180,16 @@ local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpeci end local nFacAdj2 for j = 1, #vAdj2 do - if vAdj2[j] == nFacInd then + if vAdj2[j] == FData.nFacInd then -- Se non esiste faccia adiacente a lato precedente -> inizio aperto local i = EgtIf( j > 1, j - 1, #vAdj2) - while vAdj2[i] == nFacInd do + while vAdj2[i] == FData.nFacInd do i = EgtIf( i > 1, i - 1, #vAdj2) end bOpenStart = ( vAdj2[i] < 0) -- Se non esiste faccia adiacente a lato successivo -> fine aperto local k = EgtIf( j < #vAdj2, j + 1, 1) - while vAdj2[k] == nFacInd do + while vAdj2[k] == FData.nFacInd do k = EgtIf( k < #vAdj2, k + 1, 1) end bOpenEnd = ( vAdj2[k] < 0) @@ -1172,12 +1224,12 @@ local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpeci dMaxMat = TI.dMaxMat or dMaxMat end -- Se massimo materiale utensile è molto inferiore dell'elevazione non faccio la lavorazione e do un warning - if dMaxMat > 0 and dMaxMat + 15 < dElev + dCollSic then + if dMaxMat > 0 and dMaxMat + 15 < FData.dFacElev + dCollSic then local sWarn = 'Warning : skipped milling; elevation bigger than max tool depth' return true, sWarn, dMaxMat end -- Calcolo uso faccia - local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ()) + local nFaceUse = BL.GetNearestParalOpposite( FData.rfFac:getVersZ()) -- inserisco la lavorazione di fresatura local sName = 'Mill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) @@ -1196,7 +1248,7 @@ local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpeci EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) -- imposto posizione braccio porta testa local nSCC = MCH_SCC.ADIR_YM - if rfFac:getVersZ():getY() > 100 * GEO.EPS_ZERO then + if FData.rfFac:getVersZ():getY() > 100 * GEO.EPS_ZERO then nSCC = MCH_SCC.ADIR_YP end EgtSetMachiningParam( MCH_MP.SCC, nSCC) @@ -1217,19 +1269,19 @@ local function MakeByMill( Proc, nFacInd, rfFac, dH, dV, dElev, dCollSic, bSpeci EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenStart, dTDiam / 2, - dTDiam / 2)) -- confronto la faccia applicata nella lavorazione (faccia adiacente) con la seconda faccia passata nella funzione -- se corrispondono allora aggiungo una estensione nei lati chiusi pari all'elevazione della stessa faccia corrispondente - if nFacAdj == nFacInd2 then + if nFacAdj == FData.nFacInd2 then if not bOpenStart then - EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev2) + EgtSetMachiningParam( MCH_MP.LOPERP, FData.dFacElev2) EgtSetMachiningParam( MCH_MP.LOTANG, 0) end if not bOpenEnd then - EgtSetMachiningParam( MCH_MP.LIPERP, dFacElev2) + EgtSetMachiningParam( MCH_MP.LIPERP, FData.dFacElev2) EgtSetMachiningParam( MCH_MP.LITANG, 0) end end end -- applico elevazione - local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 1) .. ';' + local sNotes = 'MaxElev=' .. EgtNumToString( FData.dFacElev, 1) .. ';' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) else EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenEnd, 0, - dTDiam / 2)) @@ -1966,7 +2018,7 @@ local function MakeSharpCleanCorner( Proc, nFacInd, dDiam) local vtN3 = EgtSurfTmFacetNormVersor( Proc.Id, tFacAdj[nIdLine][2], GDB_ID.ROOT) -- trovo il punto sulla superfice di riferimento local _, ptLocP1, ptLocP2 = EgtSurfTmFacetsContact( Proc.Id, nFacInd, tFacAdj[nIdLine][1], GDB_ID.ROOT) - local nIdIniPoint, nIdEndPoint = GetIdIniEndPoints(ptLocP1, ptLocP2, tFacAdj[nIdLine]) + local nIdIniPoint, nIdEndPoint = GetIdIniEndPoints( ptLocP1, ptLocP2, tFacAdj[nIdLine]) -- versore direzione local vtExtr = tFacAdj[nIdLine][nIdIniPoint] - tFacAdj[nIdLine][nIdEndPoint] vtExtr:normalize() @@ -2126,7 +2178,7 @@ local function MakeDrillOnCorner( Proc, nFacInd, dDiam, bSpecialMach) end -- trovo il punto sulla superfice di riferimento local _, ptLocP1, ptLocP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, tFacAdj[nIdLine][1], GDB_ID.ROOT) - local nIdIniPoint, nIdEndPoint = GetIdIniEndPoints(ptLocP1, ptLocP2, tFacAdj[nIdLine]) + local nIdIniPoint, nIdEndPoint = GetIdIniEndPoints(ptLocP1, ptLocP2, tFacAdj[nIdLine]) -- inserisco foro if nIdIniPoint and nIdEndPoint then local vtExtr @@ -2237,7 +2289,7 @@ local function MakeDrillOnCorner( Proc, nFacInd, dDiam, bSpecialMach) EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() - EgtSetOperationMode( nMchId, false) + EgtSetOperationMode( nMchId, false) return false, sErr else local _, sWarn = EgtGetMachMgrWarning( 0) @@ -2304,7 +2356,6 @@ end --------------------------------------------------------------------- local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho) - local nAuxId1, nAuxId2 if nNumIdAux == 1 then -- fondo tra loro le curve compatibili EgtMergeCurvesInCurveCompo( nPathInt) @@ -2379,7 +2430,7 @@ local function ExtractExternalPaths( nPathInt, nNumIdAux, vtOrtho) end for i = 1, #tChamPath do -- modifico estrusione percorso - ModifyPathExtrusion(tChamPath[i], sDeleteByDir, dMaxVal, 10 * GEO.EPS_SMALL) + ModifyPathExtrusion( tChamPath[i], sDeleteByDir, dMaxVal, 10 * GEO.EPS_SMALL) end if #tChamPath == 1 then return tChamPath[1], 1, nil @@ -2523,10 +2574,7 @@ local function MakeChamfer( Proc, bIs3Faces, vtOrtho, nSurfInt) end --------------------------------------------------------------------- -local function MakeByMillAsSaw( Proc, nFacInd, - rfFac, dH, dV, dElev, - nBottomFace, sMillingOnSide, - dSawDiam, dSawThick) +local function MakeByMillAsSaw( Proc, FData, nBottomFace, sMillingOnSide, dSawDiam, dSawThick) local sWarn -- ottengo la distanza tra la fine del pezzo e il pezzo successivo local dDistToNextPiece = EgtGetInfo( _nRawId, 'BDST', 'd') or 5. @@ -2540,7 +2588,7 @@ local function MakeByMillAsSaw( Proc, nFacInd, end end -- Recupero le facce adiacenti alla principale (solo quelle esistenti) - local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) + local vAdj = GetValidFacetAdjacencies( Proc.Id, FData.nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' EgtOutLog( sErr) @@ -2551,12 +2599,12 @@ local function MakeByMillAsSaw( Proc, nFacInd, local nFacAdj local dMaxLen = 0 for i = 1, #vAdj do - local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, FData.nFacInd, vAdj[i], GDB_ID.ROOT) local dLen = dist( ptP1, ptP2) if dLen > dMaxLen then nFacAdj = vAdj[i] dMaxLen = dLen - EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) + EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, FData.dH, FData.dV), 3) end end if not nFacAdj then @@ -2566,8 +2614,8 @@ local function MakeByMillAsSaw( Proc, nFacInd, end -- Riordino le dimensioni per avere dH come lato lungo e dV come perpendicolare local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacAdj, GDB_ID.ROOT) - if abs( vtN * rfFac:getVersX()) > abs( vtN * rfFac:getVersY()) then - dH, dV = dV, dH + if abs( vtN * FData.rfFac:getVersX()) > abs( vtN * FData.rfFac:getVersY()) then + FData.dH, FData.dV = FData.dV, FData.dH end -- Determino se estremi aperti o chiusi local bOpenStart = false @@ -2577,10 +2625,10 @@ local function MakeByMillAsSaw( Proc, nFacInd, local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,'), 3) for j = 1, #vAdj2 do - if vAdj2[j] == nFacInd then + if vAdj2[j] == FData.nFacInd then -- Se non esiste faccia adiacente a lato precedente -> inizio aperto local i = EgtIf( j > 1, j - 1, #vAdj2) - while vAdj2[i] == nFacInd do + while vAdj2[i] == FData.nFacInd do i = EgtIf( i > 1, i - 1, #vAdj2) end bOpenStart = ( vAdj2[i] < 0) @@ -2590,7 +2638,7 @@ local function MakeByMillAsSaw( Proc, nFacInd, end -- Se non esiste faccia adiacente a lato successivo -> fine aperto local k = EgtIf( j < #vAdj2, j + 1, 1) - while vAdj2[k] == nFacInd do + while vAdj2[k] == FData.nFacInd do k = EgtIf( k < #vAdj2, k + 1, 1) end bOpenEnd = ( vAdj2[k] < 0) @@ -2606,29 +2654,29 @@ local function MakeByMillAsSaw( Proc, nFacInd, -- Recupero la lavorazione di lama local sCutting = sMillingOnSide -- Calcolo uso faccia - local nFaceUse = BL.GetNearestOrthoOpposite( rfFac:getVersZ()) + local nFaceUse = BL.GetNearestOrthoOpposite( FData.rfFac:getVersZ()) local dStartDist = -1 local dEndDist = -1 -- calcolo eventuali arretramenti lama if not bOpenStart then local dRadius = dSawDiam / 2 - local dCat1 = dRadius - dElev - dStartDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1)) + local dCat1 = dRadius - FData.dFacElev + dStartDist = sqrt( ( dRadius * dRadius) - ( dCat1 * dCat1)) end if not bOpenEnd then if not bOpenStart then dEndDist = dStartDist else local dRadius = dSawDiam / 2 - local dCat1 = dRadius - dElev - dEndDist = sqrt( ( dRadius * dRadius) - (dCat1 * dCat1)) + local dCat1 = dRadius - FData.dFacElev + dEndDist = sqrt( ( dRadius * dRadius) - ( dCat1 * dCat1)) end end -- Eseguo i tagli - local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick) + local nStep = ceil( ( FData.dV - 10 * GEO.EPS_SMALL) / dSawThick) local dStep = 0 if nStep > 1 then - dStep = ( dV - dSawThick) / ( nStep - 1) + dStep = ( FData.dV - dSawThick) / ( nStep - 1) end for i = 1, nStep do local dOffs = ( i - 1) * dStep @@ -2648,7 +2696,7 @@ local function MakeByMillAsSaw( Proc, nFacInd, end end -- in base all'elevazione calcolo l'impronta della lama - local dUsedBladeLen = sqrt( ((dSawDiam / 2) * (dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev))) + local dUsedBladeLen = sqrt( ((dSawDiam / 2) * (dSawDiam / 2)) - ( ( (dSawDiam / 2) - FData.dFacElev) * ( (dSawDiam / 2) - FData.dFacElev))) -- controllo direzione taglio e se il minimo della feature sborda in coda if abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then -- do avviso che la lama può sbordare nel pezzo successivo @@ -2660,8 +2708,7 @@ local function MakeByMillAsSaw( Proc, nFacInd, end --------------------------------------------------------------------- -local function MakeByChainOrSaw( Proc, nFacInd, - rfFac, dH, dV, dElev, +local function MakeByChainOrSaw( Proc, FData, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFacesMaster, nBottomFace, nSurfInt, bIs3Faces) @@ -2696,7 +2743,7 @@ local function MakeByChainOrSaw( Proc, nFacInd, end end -- Recupero le facce adiacenti alla principale (solo quelle esistenti) - local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) + local vAdj = GetValidFacetAdjacencies( Proc.Id, FData.nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' EgtOutLog( sErr) @@ -2707,12 +2754,12 @@ local function MakeByChainOrSaw( Proc, nFacInd, local nFacAdj local dMaxLen = 0 for i = 1, #vAdj do - local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local _, ptP1, ptP2, _ = EgtSurfTmFacetsContact( Proc.Id, FData.nFacInd, vAdj[i], GDB_ID.ROOT) local dLen = dist( ptP1, ptP2) if dLen > dMaxLen then nFacAdj = vAdj[i] dMaxLen = dLen - EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, dH, dV), 3) + EgtOutLog( string.format( 'Adjac=%d Len=%.3f H=%.3f V=%.3f', vAdj[i], dLen, FData.dH, FData.dV), 3) end end if not nFacAdj then @@ -2722,8 +2769,8 @@ local function MakeByChainOrSaw( Proc, nFacInd, end -- Riordino le dimensioni per avere dH come lato lungo e dV come perpendicolare local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacAdj, GDB_ID.ROOT) - if abs( vtN * rfFac:getVersX()) > abs( vtN * rfFac:getVersY()) then - dH, dV = dV, dH + if abs( vtN * FData.rfFac:getVersX()) > abs( vtN * FData.rfFac:getVersY()) then + FData.dH, FData.dV = FData.dV, FData.dH end -- Determino se estremi aperti o chiusi local bOpenStart = false @@ -2734,10 +2781,10 @@ local function MakeByChainOrSaw( Proc, nFacInd, local vAdj2 = EgtSurfTmFacetAdjacencies( Proc.Id, nFacAdj)[1] EgtOutLog( 'Adj2=' .. table.concat( vAdj2, ' ,'), 3) for j = 1, #vAdj2 do - if vAdj2[j] == nFacInd then + if vAdj2[j] == FData.nFacInd then -- Se non esiste faccia adiacente a lato precedente -> inizio aperto local i = EgtIf( j > 1, j - 1, #vAdj2) - while vAdj2[i] == nFacInd do + while vAdj2[i] == FData.nFacInd do i = EgtIf( i > 1, i - 1, #vAdj2) end bOpenStart = ( vAdj2[i] < 0) @@ -2747,7 +2794,7 @@ local function MakeByChainOrSaw( Proc, nFacInd, end -- Se non esiste faccia adiacente a lato successivo -> fine aperto local k = EgtIf( j < #vAdj2, j + 1, 1) - while vAdj2[k] == nFacInd do + while vAdj2[k] == FData.nFacInd do k = EgtIf( k < #vAdj2, k + 1, 1) end bOpenEnd = ( vAdj2[k] < 0) @@ -2769,12 +2816,12 @@ local function MakeByChainOrSaw( Proc, nFacInd, end -- se lavorazione sulle teste e altezza trave supera il limite ( che causa collisione con la forcella) e direzione taglio lungo la Z -- e limite profondità BeamData è maggiore del taglio massimo lama, assegno il massimo affondamento pari al limite profondità del BeamData - if bOpenStart and bOpenEnd and _bForceUseBlade and ( Proc.Head or Proc.Tail) and abs(rfFac:getVersY():getY()) > 0.866 and + if bOpenStart and bOpenEnd and _bForceUseBlade and ( Proc.Head or Proc.Tail) and abs( FData.rfFac:getVersY():getY()) > 0.866 and _b3Solid:getDimZ() > BD.MIN_DIM_HBEAM and dSawMaxDepth > BD.MAX_DIM_HTCUT_HBEAM then dSawMaxDepth = BD.MAX_DIM_HTCUT_HBEAM end -- Se entrambi gli estremi sono aperti e possibile, lavoro con la lama - if bOpenStart and bOpenEnd and _bForceUseBlade and dElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then + if bOpenStart and bOpenEnd and _bForceUseBlade and FData.dFacElev < dSawMaxDepth + 10 * GEO.EPS_SMALL then -- Recupero la lavorazione di lama local sCutting = ML.FindCutting( 'HeadSide') if not sCutting then @@ -2790,18 +2837,18 @@ local function MakeByChainOrSaw( Proc, nFacInd, dSawDiam = TI.dDiam or dSawDiam dSawThick = TI.dThick end - if dSawThick > dV + 10 * GEO.EPS_SMALL then + if dSawThick > FData.dV + 10 * GEO.EPS_SMALL then local sErr = 'Error : sawblade too thick' EgtOutLog( sErr) return false, sErr end -- Calcolo uso faccia - local nFaceUse = BL.GetNearestOrthoOpposite( rfFac:getVersZ()) + local nFaceUse = BL.GetNearestOrthoOpposite( FData.rfFac:getVersZ()) -- Eseguo i tagli - local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick) + local nStep = ceil( ( FData.dV - 10 * GEO.EPS_SMALL) / dSawThick) local dStep = 0 if nStep > 1 then - dStep = ( dV - dSawThick) / ( nStep - 1) + dStep = ( FData.dV - dSawThick) / ( nStep - 1) end for i = 1, nStep do local dOffs = ( i - 1) * dStep @@ -2809,7 +2856,7 @@ local function MakeByChainOrSaw( Proc, nFacInd, if not bOk then return bOk, sErr end end -- in base all'elevazione calcolo l'impronta della lama - local dUsedBladeLen = sqrt( ((dSawDiam / 2) * (dSawDiam / 2)) - ( ( (dSawDiam / 2) - dElev) * ( (dSawDiam / 2) - dElev))) + local dUsedBladeLen = sqrt( ( ( dSawDiam / 2) * ( dSawDiam / 2)) - ( ( ( dSawDiam / 2) - FData.dFacElev) * ( ( dSawDiam / 2) - FData.dFacElev))) -- controllo direzione taglio e se il minimo della feature sborda in coda if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL and dDistToNextPiece < dUsedBladeLen then -- do avviso che la lama può sbordare nel pezzo successivo @@ -2835,28 +2882,28 @@ local function MakeByChainOrSaw( Proc, nFacInd, dSawThick = TI.dThick or dSawThick dMaxDepth = TI.dMaxDepth or dMaxDepth end - if dSawThick > dV + 10 * GEO.EPS_SMALL then + if dSawThick > FData.dV + 10 * GEO.EPS_SMALL then local sErr = 'Error : chainsaw too thick' EgtOutLog( sErr) return false, sErr end local bGoFromHead = true -- se la lunghezza utensile non riesce ad arrivare sul fondo assegno la possibilità di lavorare di testa o di fianco - if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then + if FData.dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then -- lavora di testa se è un tunnel, lavora di fianco se non è un tunnel bGoFromHead = not bOrthoFaces end -- se continuo a lavorare di testa if bGoFromHead then -- Calcolo uso faccia - local nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ()) + local nFaceUse = BL.GetNearestParalOpposite( FData.rfFac:getVersZ()) -- Calcolo normale faccia adiacente local vtN = EgtSurfTmFacetNormVersor( Proc.Id, nFacAdj, GDB_ID.ROOT) -- Verifico se necessarie più passate - local nStep = ceil( ( dV - 10 * GEO.EPS_SMALL) / dSawThick) + local nStep = ceil( ( FData.dV - 10 * GEO.EPS_SMALL) / dSawThick) local dStep = 0 if nStep > 1 then - dStep = ( dV - dSawThick) / ( nStep - 1) + dStep = ( FData.dV - dSawThick) / ( nStep - 1) end for i = 1, nStep do -- Applico la lavorazione con sega a catena a questa faccia @@ -2874,17 +2921,17 @@ local function MakeByChainOrSaw( Proc, nFacInd, -- controllo direzione taglio e se il minimo della feature sborda in coda if not Proc.Tail and abs( vtN:getX()) < GEO.EPS_SMALL and abs( _b3Solid:getMin():getX() - Proc.Box:getMin():getX()) < 100 * GEO.EPS_SMALL then -- se ho lato partenza aperto e lato uscita chiuso e direzione lato chiuso è negativa, allora controllo uscita lama - if bOpenStart and not bOpenEnd and vtNE:getX() < -0.99 and dDistToNextPiece < (dSawWidth / 2) then + if bOpenStart and not bOpenEnd and vtNE:getX() < -0.99 and dDistToNextPiece < ( dSawWidth / 2) then -- imposto accorciamento iniziale per estremi aperti/chiusi - EgtSetMachiningParam( MCH_MP.STARTADDLEN, dDistToNextPiece - 1 - (dSawWidth / 2)) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dDistToNextPiece - 1 - ( dSawWidth / 2)) else -- imposto accorciamento iniziale per estremi aperti/chiusi EgtSetMachiningParam( MCH_MP.STARTADDLEN, EgtIf( bOpenStart, 0, - dSawWidth / 2)) end -- se ho lato uscita aperto e lato partenza chiuso e direzione lato partenza è negativa, allora controllo uscita lama - if bOpenEnd and not bOpenStart and vtNS:getX() < -0.99 and dDistToNextPiece < (dSawWidth / 2) then + if bOpenEnd and not bOpenStart and vtNS:getX() < -0.99 and dDistToNextPiece < ( dSawWidth / 2) then -- imposto accorciamento finale per estremi aperti/chiusi - EgtSetMachiningParam( MCH_MP.ENDADDLEN, dDistToNextPiece - 1 - (dSawWidth / 2)) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dDistToNextPiece - 1 - ( dSawWidth / 2)) else -- imposto accorciamento finale per estremi aperti/chiusi EgtSetMachiningParam( MCH_MP.ENDADDLEN, EgtIf( bOpenEnd, 0, - dSawWidth / 2)) @@ -2896,19 +2943,19 @@ local function MakeByChainOrSaw( Proc, nFacInd, end -- imposto angolo 3° asse rot e eventuale angolo suggerito per inizio EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 1)) - EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, rfFac:getVersZ())) + EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, FData.rfFac:getVersZ())) -- imposto offset radiale local dOffs = ( i - 1) * dStep EgtSetMachiningParam( MCH_MP.OFFSR, dOffs) -- se necessario, limito l'affondamento - if dElev > dMaxDepth + 10 * GEO.EPS_SMALL then - sWarn = 'Warning in LapJoint : elevation (' .. EgtNumToString( dElev, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' - dDepth = dMaxDepth - dElev + if FData.dFacElev > dMaxDepth + 10 * GEO.EPS_SMALL then + sWarn = 'Warning in LapJoint : elevation (' .. EgtNumToString( FData.dFacElev, 1) .. ') bigger than max tool depth (' .. EgtNumToString( dMaxDepth, 1) .. ')' + dDepth = dMaxDepth - FData.dFacElev EgtOutLog( sWarn) - EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH '..EgtNumToString( dDepth, 1)) + EgtSetMachiningParam( MCH_MP.DEPTH_STR, 'TH ' .. EgtNumToString( dDepth, 1)) end -- imposto elevazione - local sNotes = 'MaxElev=' .. EgtNumToString( dElev, 2) .. ';' + local sNotes = 'MaxElev=' .. EgtNumToString( FData.dFacElev, 2) .. ';' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not EgtApplyMachining( true, false) then @@ -2919,7 +2966,7 @@ local function MakeByChainOrSaw( Proc, nFacInd, end -- impostazione alternativa angolo 3° asse rot EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, GetChainSawBlockedAxis( 2)) - EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, rfFac:getVersZ())) + EgtSetMachiningParam( MCH_MP.INITANGS, GetChainSawInitAngs( vtN, FData.rfFac:getVersZ())) if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() EgtSetOperationMode( nMchFId, false) @@ -2958,7 +3005,7 @@ local function MakeByChainOrSaw( Proc, nFacInd, local nFaceUse -- se non è un tunnel a 4 facce if Proc.Fct < 4 then - nFaceUse = BL.GetNearestParalOpposite( rfFac:getVersZ(), vtN) + nFaceUse = BL.GetNearestParalOpposite( FData.rfFac:getVersZ(), vtN) -- altrimenti vero tunnel (solo sopra-sotto o davanti-dietro) else if abs( vtOrtho:getZ()) >= 0.707 then @@ -2996,11 +3043,11 @@ local function MakeByChainOrSaw( Proc, nFacInd, -- altrimenti vero tunnel (solo sopra-sotto o davanti-dietro) else -- se possibile aumento l'affondamento pari al raggio corner + 1 - if dMaxMat2 > (dDepth + dSawCornerRad2 + 1) then - EgtSetMachiningParam( MCH_MP.DEPTH, (dDepth + dSawCornerRad2 + 1)) + if dMaxMat2 > ( dDepth + dSawCornerRad2 + 1) then + EgtSetMachiningParam( MCH_MP.DEPTH, ( dDepth + dSawCornerRad2 + 1)) -- se massimo affondamento supera altezza fessura, uso massimo affondamento - elseif dMaxMat2 > (dDepth + 1) then - EgtSetMachiningParam( MCH_MP.DEPTH, (dMaxMat2 - 1)) + elseif dMaxMat2 > ( dDepth + 1) then + EgtSetMachiningParam( MCH_MP.DEPTH, ( dMaxMat2 - 1)) -- se massimo affondamento utensile inferiore fessura, setto affondamento ed emetto warning elseif dMaxMat2 < dDepth then EgtSetMachiningParam( MCH_MP.DEPTH, dMaxMat2) @@ -3205,19 +3252,18 @@ end --------------------------------------------------------------------- local function MachineByMill( Proc, tvtN, nBaseFace, nSideFace, ptPs, tDimAndRef, nDiffWidth, nUseRoughTool, dAng, sPocketing, sTuuidPk, dPrevFaceElev) - - local sMchFind = 'Pocket' - local dAngLimit = 40 - - -- se feature é larga come trave imposto openpocket - if nDiffWidth == 0 then - sMchFind = 'OpenPocket' - -- altrimenti non è passante disabilito il truciolatore - else - nUseRoughTool = 0 - end -- se angolo tra le facce maggiore di 90, inserisco la contornatura o svuotatura del lato più corto if ( 180 + dAng) > 90.1 then + local sMchFind = 'Pocket' + local dAngLimit = 40 + + -- se feature é larga come trave imposto openpocket + if nDiffWidth == 0 then + sMchFind = 'OpenPocket' + -- altrimenti non è passante disabilito il truciolatore + else + nUseRoughTool = 0 + end -- calcolo l'angolo dalla verticale dall'angolo tra le due facce, perchè la feature potrebbe essere ruotata sulla Z locale della -- faccia principale e quindi la componente X del versore della faccia potrebbe dare un valore non coerente local dDiffFromSqAng = dAng + 90 @@ -3400,13 +3446,12 @@ end --------------------------------------------------------------------- local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster, bMillDown) - local nFirstMachId local bOrthoFaces local sWarn local sMchFind = 'Pocket' local dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, nSurfInt - local bBadMach = false + local bBadMach = false if sMchFindMaster and #sMchFindMaster > 0 then sMchFind = sMchFindMaster end @@ -3708,7 +3753,7 @@ local function MakeByPockets( Proc, sMchFindMaster, bIs3Faces, bOrthoFacesMaster local dDepth = 0 local dActMaxDepth = EgtIf( bFacPocketDn, dMaxDepthDn, dMaxDepth) if dActMaxDepth < dFacElev + dFacCollSic then - dDepth = dActMaxDepth - ( dFacElev + dFacCollSic) + dDepth = dActMaxDepth - dFacElev + dFacCollSic end EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) -- dichiaro non si generano sfridi per VMill @@ -4184,20 +4229,19 @@ local function ManageAntiSplintByMill( Proc, nFacInd, bMillDown, bDoubleSide, end --------------------------------------------------------------------- -local function MakeBySideMill( Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dToolDiam, bHeadDir) - +local function MakeBySideMill( Proc, FData, dMaxMat, dToolDiam, bHeadDir) local dH, dV -- recupero la larghezza della faccia perpendicolarmente alle altre 2 - local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( nFacInd == 0, 1, 0), GDB_ID.ROOT) - local vtX = vtN2 ^ vtN - local frRef = Frame3d( ptC, ptC + 100 * vtX, ptC + 100 * vtN2) - local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, nFacInd, GDB_BB.STANDARD, frRef) + local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, EgtIf( FData.nFacInd == 0, 1, 0), GDB_ID.ROOT) + local vtX = vtN2 ^ FData.vtN + local frRef = Frame3d( FData.ptC, FData.ptC + 100 * vtX, FData.ptC + 100 * vtN2) + local b3Ref = EgtSurfTmGetFacetBBoxRef( Proc.Id, FData.nFacInd, GDB_BB.STANDARD, frRef) if b3Ref then dV = b3Ref:getDimY() dH = b3Ref:getDimX() end -- se lavorazione da sotto e lunga, va divisa in due metà - local bHalf = ( vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200)) + local bHalf = ( FData.vtN:getZ() < -0.5 and dH > ( BD.MAX_LEN_BH_FROM_BOTTOM or 200)) -- inserisco la lavorazione di fresatura local sName = 'BHMill_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = EgtAddMachining( sName, sMilling) @@ -4208,14 +4252,14 @@ local function MakeBySideMill( Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dTool end sName = EgtGetName( nMchFId) -- aggiungo geometria - EgtSetMachiningGeometry( {{ Proc.Id, nFacInd}}) + EgtSetMachiningGeometry( {{ Proc.Id, FData.nFacInd}}) -- imposto uso del lato faccia EgtSetMachiningParam( MCH_MP.FACEUSE, EgtIf( bHeadDir, MCH_MILL_FU.PARAL_LEFT, MCH_MILL_FU.PARAL_RIGHT)) -- calcolo step effettivo ed elevazione local dVcalc = dV - dMaxMat local dStep = EgtMdbGetCurrMachiningParam( MCH_MP.STEP) or dMaxMat local nStep = ceil( dVcalc / dStep) - if vtN:getZ() < - 0.5 and ( nStep % 2) == 0 then + if FData.vtN:getZ() < - 0.5 and ( nStep % 2) == 0 then nStep = nStep + 1 end dStep = dVcalc / nStep + 0.1 @@ -4225,24 +4269,24 @@ local function MakeBySideMill( Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dTool sNotes = sNotes .. 'VMRS=0;' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- attacchi e uscite - if vtN:getZ() > -0.5 then + if FData.vtN:getZ() > -0.5 then EgtSetMachiningParam( MCH_MP.LITANG, 0) - EgtSetMachiningParam( MCH_MP.LIPERP, dFacElev + BD.CUT_SIC) + EgtSetMachiningParam( MCH_MP.LIPERP, FData.dFacElev + BD.CUT_SIC) else EgtSetMachiningParam( MCH_MP.LITANG, dToolDiam / 2 + BD.CUT_SIC) EgtSetMachiningParam( MCH_MP.LIPERP, 0) EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LO.LINEAR) EgtSetMachiningParam( MCH_MP.LOTANG, 0) - EgtSetMachiningParam( MCH_MP.LOPERP, dFacElev + BD.COLL_SIC) + EgtSetMachiningParam( MCH_MP.LOPERP, FData.dFacElev + BD.COLL_SIC) if bHalf then EgtSetMachiningParam( MCH_MP.ENDADDLEN, - dH / 2) end end -- tipo passate multiple - local nStepType = EgtIf( ( Proc.HeadDir and vtN:getY() < -0.5) or ( not Proc.HeadDir and vtN:getY() > 0.5), MCH_MILL_ST.ONEWAY, MCH_MILL_ST.ZIGZAG) + local nStepType = EgtIf( ( Proc.HeadDir and FData.vtN:getY() < -0.5) or ( not Proc.HeadDir and FData.vtN:getY() > 0.5), MCH_MILL_ST.ONEWAY, MCH_MILL_ST.ZIGZAG) EgtSetMachiningParam( MCH_MP.STEPTYPE, nStepType) -- imposto posizione braccio porta testa - local nSCC = EgtIf( ( vtN:getY() > 0.5 or ( bHeadDir and vtN:getZ() > 0.5 ) or ( not bHeadDir and vtN:getZ() < -0.5)), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) + local nSCC = EgtIf( ( FData.vtN:getY() > 0.5 or ( bHeadDir and FData.vtN:getZ() > 0.5 ) or ( not bHeadDir and FData.vtN:getZ() < -0.5)), MCH_SCC.ADIR_YP, MCH_SCC.ADIR_YM) EgtSetMachiningParam( MCH_MP.SCC, nSCC) -- eseguo if not EgtApplyMachining( true, false) then @@ -4276,20 +4320,13 @@ local function MakeBySideMill( Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dTool end --------------------------------------------------------------------- -local function MakeSpecialThreeFaces( Proc) - - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - -- entrambe le facce non devono essere orientate verso il basso - local _, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - local _, vtN2 = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) +local function MakeSpecialThreeFaces( Proc, FData) -- se orientata verso il basso, verifico l'alternativa - if vtN:getZ() < BD.NZ_MINA and vtN2:getZ() < BD.NZ_MINA then + if FData.vtN:getZ() < BD.NZ_MINA and FData.vtN2:getZ() < BD.NZ_MINA then local sErr = 'Error : special LapJoint from bottom impossible' EgtOutLog( sErr) return false, sErr end - local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) - local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd2, GDB_ID.ROOT) -- eventuali tagli preliminari do local bOk, sErr = MakePreCuts( Proc) @@ -4308,28 +4345,23 @@ local function MakeSpecialThreeFaces( Proc) if Q_USE_ROUGH_TOOL == 1 then sMchFind = 'OpenPocket' end - local dDiam = min( dH, dV) - local dDiam2 = min( dH2, dV2) + local dDiam = min( FData.dH, FData.dV) + local dDiam2 = min( FData.dH2, FData.dV2) local dCollSic = 2 * BD.COLL_SIC local dCollSic2 = 2 * BD.COLL_SIC - if abs( vtN:getX()) > 0.7 or abs( vtN:getY()) > 0.7 or abs( vtN:getZ()) > 0.7 then dCollSic = 0 end - if abs( vtN2:getX()) > 0.7 or abs( vtN2:getY()) > 0.7 or abs( vtN2:getZ()) > 0.7 then dCollSic2 = 0 end + if abs( FData.vtN:getX()) > 0.7 or abs( FData.vtN:getY()) > 0.7 or abs( FData.vtN:getZ()) > 0.7 then dCollSic = 0 end + if abs( FData.vtN2:getX()) > 0.7 or abs( FData.vtN2:getY()) > 0.7 or abs( FData.vtN2:getZ()) > 0.7 then dCollSic2 = 0 end - local sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2) - local nPockFace = nFacInd2 + local sPocketing = ML.FindPocketing( sMchFind, dDiam2, FData.dFacElev2 + dCollSic2) + local nPockFace = FData.nFacInd2 -- se non trova una svuotatura adatta provo ad assegnarla all'altra faccia if not sPocketing then dDiam, dDiam2 = dDiam2, dDiam dCollSic, dCollSic2 = dCollSic2, dCollSic - nFacInd, nFacInd2 = nFacInd2, nFacInd - dH, dH2 = dH2, dH - dV, dV2 = dV2, dV - dFacElev, dFacElev2 = dFacElev2, dFacElev - rfFac, rfFac2 = rfFac2, rfFac - vtN, vtN2 = vtN2, vtN - + FData = SwapFacetsData( FData) + -- prendo a riferimento la seconda faccia per la svuotatura - sPocketing = ML.FindPocketing( sMchFind, dDiam2, dFacElev2 + dCollSic2) + sPocketing = ML.FindPocketing( sMchFind, dDiam2, FData.dFacElev2 + dCollSic2) if not sPocketing then local sErr = 'Error : '..sMchFind..' not found in library' @@ -4344,7 +4376,7 @@ local function MakeSpecialThreeFaces( Proc) local _, bIsL = TestUL( Proc) if bIsL then local bOk, sWarn - bOk, sWarn, _ = MakeByMill( Proc, nFacInd, rfFac, dH, dV, dFacElev, dCollSic, true, sMilling, nFacInd2, dFacElev2) + bOk, sWarn, _ = MakeByMill( Proc, FData, dCollSic, true, sMilling) if not bOk then return bOk, sWarn end else local sErr = 'Error : Impossible mill special LapJoint' @@ -4366,7 +4398,7 @@ local function MakeSpecialThreeFaces( Proc) -- imposto uso faccia EgtSetMachiningParam( MCH_MP.FACEUSE, MCH_MILL_FU.ORTHO_CONT) -- imposto posizione braccio porta testa - if vtN:getY() < GEO.EPS_SMALL then + if FData.vtN:getY() < GEO.EPS_SMALL then EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YM) else EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_YP) @@ -4376,7 +4408,7 @@ local function MakeSpecialThreeFaces( Proc) EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALIN) end -- imposto elevazione - local sNotes = 'MaxElev=' .. EgtNumToString( dFacElev2, 1) .. ';' + local sNotes = 'MaxElev=' .. EgtNumToString( FData.dFacElev2, 1) .. ';' EgtSetMachiningParam( MCH_MP.USERNOTES, sNotes) -- eseguo if not EgtApplyMachining( true, false) then @@ -4477,16 +4509,14 @@ local function MakeByChainsaw( Proc, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdF end --------------------------------------------------------------------- -local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, bSpecialMillOnSide, +local function MakeSidePocketings( Proc, FData, dCollSic, bSpecialMillOnSide, nBottomFace, sMillingOnSide, dToolDiamOnSide, dThickMillOnSide, - bSinglePart, bIsU, bIsL, dDiam, bMillDown, bMillUp, sMchFind, sMchFindBackUp) + bSinglePart, bIsU, bIsL, dDiam, bMillDown, bMillUp, sMchFind, sMchFindBackUp) local bTryWithBlades = true local nOk, bOk, sStat, sErr, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nSurfInt if bSpecialMillOnSide then -- eseguo - bOk, sWarn = MakeByMillAsSaw( Proc, nFacInd, rfFac, dH, dV, dFacElev, - nBottomFace, sMillingOnSide, - dToolDiamOnSide, dThickMillOnSide) + bOk, sWarn = MakeByMillAsSaw( Proc, FData, nBottomFace, sMillingOnSide, dToolDiamOnSide, dThickMillOnSide) if bOk then return 1, true, sWarn end @@ -4496,19 +4526,15 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame if bTryWithBlades and _nChamfer < 2 then -- anche su macchine con testa da sotto, la sega a catena è solo da sopra - if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + if FData.vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and FData.nFacInd2 then + FData = SwapFacetsData( FData) end -- eseguo (come 3 faces) - bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nFacInd, - rfFac, dH, dV, dFacElev, + bOk, sWarn, sStat = MakeByChainOrSaw( Proc, FData, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, - bOrthoFaces, nBottomFace, - nSurfInt, true) + bOrthoFaces, nBottomFace, nSurfInt, true) if not bOk then - -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e + -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e -- se non è possibile allora provo in seguito con lama o segacatena -- o passare subito dalla lavorazione con lama/sega catena if Proc.Fct == 3 and bIsU then @@ -4578,7 +4604,7 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then local bOk local bSawDown = ( bMillDown and not bMillUp) - _, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, vtN, nFacInd, sWarn, bSawDown, true) + _, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, FData.vtN, FData.nFacInd, sWarn, bSawDown, true) if not bOk then return 1, false, sWarn end end -- in base al flag interno e al numero di facce e se ha forma ad U: provo prima la svuotatura sul fianco e @@ -4610,14 +4636,14 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, sWarn = sErr -- se ho antischeggia con fresa le inserisco if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 2 then - local _, sWarn2 = ManageAntiSplintByMill( Proc, nFacInd, bMillDown, bDoubleSide, + local _, sWarn2 = ManageAntiSplintByMill( Proc, FData.nFacInd, bMillDown, bDoubleSide, vtOrtho, nPathInt, nSurfInt, dDepth, bOneShot, nFirstMachId) sWarn = FormatWarning( sWarn, sWarn2) end -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola if Q_CONTOUR_SMALL_TOOL > 0 then - local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown, + local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, FData.nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown, bDoubleSide, vtOrtho, nPathInt, nSurfInt, dDepth, bOneShotm) if not bOk then return 1, false, sWarn2 end @@ -4634,18 +4660,15 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, -- Se la svuotatura precedente non è stata fatta e smusso non è esclusivo, provo con le lame if bTryWithBlades and _nChamfer < 2 then -- anche su macchine con testa da sotto, la sega a catena è solo da sopra - if vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and nFacInd2 then - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + if FData.vtN:getZ() < BD.NZ_MINA and BD.DOWN_HEAD and FData.nFacInd2 then + FData = SwapFacetsData( FData) end -- eseguo (non 3 faces) - bOk, sWarn, sStat = MakeByChainOrSaw( Proc, nFacInd, - rfFac, dH, dV, dFacElev, + bOk, sWarn, sStat = MakeByChainOrSaw( Proc, FData, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace, bOrthoFaces, nBottomFace, nSurfInt) if not bOk and sStat == 'MNF' then - _, sPocketing = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, nil, sMchFind) + _, sPocketing = VerifyPocket( Proc, dDiam, FData.dFacElev + dCollSic, nil, sMchFind) if sPocketing then sWarn = '' else @@ -4657,7 +4680,7 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, -- se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola if Q_CONTOUR_SMALL_TOOL > 0 then local bOk, sWarn2 - bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, 100, Q_CONTOUR_SMALL_TOOL, bMillDown) + bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, FData.nFacInd, 100, Q_CONTOUR_SMALL_TOOL, bMillDown) if not bOk then return 1, false, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) end @@ -4676,50 +4699,39 @@ local function MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, end --------------------------------------------------------------------- -local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev, dFacElev2) - -- dati della faccia - local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) +local function MakePocketingOrMilling( Proc, FData, bSinglePart) -- verifico se forma ad U o L local bIsU, bIsL = TestUL( Proc) local bUseOtherFace -- se orientata verso il basso e non c'è testa da sotto, verifico l'alternativa - if vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD and nFacInd2 then - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd2, GDB_ID.ROOT) - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev + if FData.vtN:getZ() < BD.NZ_MINA and not BD.DOWN_HEAD and FData.nFacInd2 then + FData = SwapFacetsData(FData) bUseOtherFace = true end -- verifico non sia orientata verso il basso o ci sia una testa dal basso - local bFaceDown = ( vtN:getZ() < BD.NZ_MINA) + local bFaceDown = ( FData.vtN:getZ() < BD.NZ_MINA) if bFaceDown and not BD.DOWN_HEAD then local sErr = 'Error : LapJoint from bottom impossible' EgtOutLog( sErr) return false, sErr end -- se forma a L e la componente in X è maggiore di 60° e non in testa allora verifico se posso utilizzare la faccia secondaria - if bIsL and abs( vtN:getX()) > 0.866 and - ( Proc.Box:getMax():getX() < _b3Solid:getMax():getX() - 10 or vtN:getX() < 0) and - ( not Proc.Tail or vtN:getX() > 0) then + if bIsL and abs( FData.vtN:getX()) > 0.866 and + ( Proc.Box:getMax():getX() < _b3Solid:getMax():getX() - 10 or FData.vtN:getX() < 0) and + ( not Proc.Tail or FData.vtN:getX() > 0) then -- se non ho scambiato la faccia if not bUseOtherFace then - if nFacInd2 then - nFacInd, nFacInd2 = nFacInd2, nFacInd - dFacElev, dFacElev2 = dFacElev2, dFacElev - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + if FData.nFacInd2 then + FData = SwapFacetsData(FData) -- altrimenti cerco la faccia secondaria per adiacenza alla principale else -- Cerco una faccia adiacente alla principale sul lato lungo - local nFacAdj, sErr = GetFaceAdj( Proc, nFacInd, dH, dV) + local nFacAdj, sErr = GetFaceAdj( Proc, FData.nFacInd, FData.dH, FData.dV) if nFacAdj < 0 then EgtOutLog( sErr) return false, sErr end - nFacInd = nFacAdj - dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) - ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) + FData = UpdateFacet1Data( Proc.Id, FData, nFacAdj) end -- altrimenti se ho già cambiato faccia do errore per impossibilità di lavorazione else @@ -4734,18 +4746,18 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa if not bOk then return false, sErr end end -- imposto altezza aggiuntiva di elevazione - local dCollSic = CalcCollisionSafety( vtN) + local dCollSic = CalcCollisionSafety( FData.vtN) -- abilitazione lavorazione da sotto - local bMillUp = ( BD.DOWN_HEAD and vtN:getZ() > -0.259) - local bMillDown = ( BD.DOWN_HEAD and vtN:getZ() < 0.342) + local bMillUp = ( BD.DOWN_HEAD and FData.vtN:getZ() > -0.259) + local bMillDown = ( BD.DOWN_HEAD and FData.vtN:getZ() < 0.342) -- settaggio voluto da Alessandro/Fabio (per fare angoli con fresa piccola) local sMchFind = 'Pocket' - local dDiam = min( dH, dV) + local dDiam = min( FData.dH, FData.dV) local bTailOnSide = ( Proc.Box:getMin():getX() - _b3Solid:getMin():getX() < 0.1 and not Proc.Tail) if ( Proc.Fct == 1) or (( Proc.Fct == 2 or Proc.Fct == 3) and bIsL) or ((( Proc.Fct == 3 and bIsU) or ( Proc.Fct == 4 and not bTailOnSide)) and bSinglePart) then sMchFind = 'OpenPocket' if bIsU then - dDiam = GetUShapeWidth( Proc, nFacInd) or dDiam + dDiam = GetUShapeWidth( Proc, FData.nFacInd) or dDiam elseif Proc.Fct == 4 then -- per rifinire gli angoli premio utensile diam 25 o da BD dDiam = min( dDiam, BD.MAXDIAM_POCK_CORNER or 30) @@ -4787,13 +4799,13 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa -- se da sotto, imposto massima lunghezza secondo la direzione local dMaxTotLen if bMillDown and BD.GetBottomToolMaxTotLen then - dMaxTotLen = BD.GetBottomToolMaxTotLen( vtN) + dMaxTotLen = BD.GetBottomToolMaxTotLen( FData.vtN) end -- ricerca lavorazione local sPocketing - local _, sMyPocketing, dMyTMaxDepth, _ = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind .. EgtIf( bMillDown, '_H2', '')) + local _, sMyPocketing, dMyTMaxDepth, _ = VerifyPocket( Proc, dDiam, FData.dFacElev + dCollSic, dMaxTotLen, sMchFind .. EgtIf( bMillDown, '_H2', '')) if not sMyPocketing and bMillUp then - _, sMyPocketing, dMyTMaxDepth, _ = VerifyPocket( Proc, dDiam, dFacElev + dCollSic, dMaxTotLen, sMchFind) + _, sMyPocketing, dMyTMaxDepth, _ = VerifyPocket( Proc, dDiam, FData.dFacElev + dCollSic, dMaxTotLen, sMchFind) bMillDown = false end --local sMyPocketing, dMyTDiam, dMyTMaxDepth = ML.FindPocketing( sMchFind .. EgtIf( bMillDown, '_H2', ''), dDiam, dFacElev + dCollSic, dMaxTotLen) @@ -4808,7 +4820,7 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa -- bMillDown = false --end if sMyPocketing and - ( dMyTMaxDepth > dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * dFacElev + dCollSic and not bIsU) or ( bIsL and nUseRoughTool == 0)) then + ( dMyTMaxDepth > FData.dFacElev + dCollSic - 10 * GEO.EPS_SMALL or ( dMyTMaxDepth > 0.8 * FData.dFacElev + dCollSic and not bIsU) or ( bIsL and nUseRoughTool == 0)) then sPocketing = sMyPocketing end if bMillDown then @@ -4836,9 +4848,9 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa while not bDeleteFace and nInt < nFaces do nInt = nInt + 1 local b3Facet = EgtSurfTmGetFacetBBoxGlob( nTestId, nInt - 1, GDB_BB.STANDARD) - local vtN = EgtSurfTmFacetNormVersor( nTestId, nInt - 1, GDB_ID.ROOT) + local vtNi = EgtSurfTmFacetNormVersor( nTestId, nInt - 1, GDB_ID.ROOT) -- se dimensione faccia sulla X - if b3Facet:getDimX() < 1 or abs( vtN:getX()) > 0.1 then + if b3Facet:getDimX() < 1 or abs( vtNi:getX()) > 0.1 then EgtSurfTmRemoveFacet( nTestId, nInt - 1) bDeleteFace = true end @@ -4860,10 +4872,10 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa EgtErase( nTestId) if bNewIsU and ( not BD.MIN_LEN_LAMELLO or - ( Proc.TotBox and Proc.TotBox:getDimX() > BD.MIN_LEN_LAMELLO) or - ( not Proc.TotBox and Proc.Box:getDimX() > BD.MIN_LEN_LAMELLO)) then + ( Proc.TotBox and Proc.TotBox:getDimX() > BD.MIN_LEN_LAMELLO) or + ( not Proc.TotBox and Proc.Box:getDimX() > BD.MIN_LEN_LAMELLO)) then -- recupero la lavorazione - if BD.DOWN_HEAD and vtN:getZ() < BD.NZ_MINA then + if BD.DOWN_HEAD and FData.vtN:getZ() < BD.NZ_MINA then sMillingOnSide = ML.FindMilling( 'SideMillAsBlade_H2') else sMillingOnSide = ML.FindMilling( 'SideMillAsBlade') @@ -4882,7 +4894,7 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa -- 2021.09.17 Su conferma di Fabio Squaratti, se la gola è più stretta dell'utensile o la profondità della gole è maggiore -- del valore parametro SIDEDEPTH (preso dalle note utente dell'utensile) allora si prosegue come se non fosse abilitata -- questo tipo di lavorazione SideMillAsBlade - if dDiam > dThickMillOnSide - 10 * GEO.EPS_SMALL and dFacElev < dMaxDepthOnSide + 10 * GEO.EPS_SMALL then + if dDiam > dThickMillOnSide - 10 * GEO.EPS_SMALL and FData.dFacElev < dMaxDepthOnSide + 10 * GEO.EPS_SMALL then bSpecialMillOnSide = true -- disabilito eventuale svuotatura sPocketing = nil @@ -4903,11 +4915,11 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa if bIsL and not bSpecialMillOnSide then -- se smusso non è esclusivo if _nChamfer < 2 then - return MakeByMill( Proc, nFacInd, rfFac, dH, dV, dFacElev, dCollSic) + return MakeByMill( Proc, FData, dCollSic) end -- altrimenti, in base alla forma, provo con svuotature di fianco o con la sega a catena o lama else - local stat, bOk, sWarn = MakeSidePocketings( Proc, nFacInd, rfFac, dH, dV, vtN, dFacElev, bSpecialMillOnSide, + local stat, bOk, sWarn = MakeSidePocketings( Proc, FData, dCollSic, bSpecialMillOnSide, nBottomFace, sMillingOnSide, dToolDiamOnSide, dThickMillOnSide, bSinglePart, bIsU, bIsL, dDiam, bMillDown, bMillUp, sMchFind, sMchFindBackUp) if stat == 1 then @@ -4935,21 +4947,21 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 1 and (( bIsU or bIsL) and ( bPassThrou or bPassEdge)) then local bOk local bSawDown = ( bMillDown and not bMillUp) - bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, vtN, nFacInd, sWarn, bSawDown) + bMadeASbyBld, bOk, sWarn = ManageAntiSplintBySaw( Proc, bIsU, FData.vtN, FData.nFacInd, sWarn, bSawDown) if not bOk then return false, sWarn end end if _nChamfer < 2 and Q_ANTISPLINT_TYPE == 2 then local bOk, sWarn2 - bOk, sWarn2 = ManageAntiSplintByMill( Proc, nFacInd, bMillDown) + bOk, sWarn2 = ManageAntiSplintByMill( Proc, FData.nFacInd, bMillDown) if not bOk then return false, sWarn2 end end -- se smusso non esclusivo if _nChamfer < 2 then -- eseguo la svuotatura della faccia principale, mi restituisce id utensile, il diametro utensile per il foro opzionale local tvtNx = {} - tvtNx[2] = vtN + tvtNx[2] = FData.vtN local bOk, sWarn2, sTuuidPk, dDiamTool - bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, ptC, tvtNx, nFacInd, sMchFind, nUseRoughTool, sPocketing, dFacElev + dCollSic) + bOk, sWarn2, sTuuidPk, dDiamTool = MakePocket( Proc, FData.ptC, tvtNx, FData.nFacInd, sMchFind, nUseRoughTool, sPocketing, FData.dFacElev + dCollSic) if not bOk then return false, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) -- se ho più di 3 facce e non di forma ad U oppure ho 3 facce e di forma ad U @@ -4957,7 +4969,7 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa -- controllo se c'è una faccia non ortogonale alla principale e la lavoro con una contornatura o svuotatura if ( ( Proc.Fct > 3 and not bIsU) or ( Proc.Fct == 3 and bIsU)) and not bMadeASbyBld then -- Recupero le facce adiacenti alla principale (solo quelle esistenti) - local vAdj = GetValidFacetAdjacencies( Proc.Id, nFacInd) + local vAdj = GetValidFacetAdjacencies( Proc.Id, FData.nFacInd) if not vAdj or #vAdj == 0 then local sErr = 'Error : main face without adjacencies' EgtOutLog( sErr) @@ -4966,17 +4978,17 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa -- Cerco una faccia adiacente alla principale con angolo > 90 local tDimAndRef = {} tvtNx = {} - tvtNx[1] = vtN - tDimAndRef[1] = { dH, dV, rfFac} + tvtNx[1] = FData.vtN + tDimAndRef[1] = { FData.dH, FData.dV, FData.rfFac} for i = 1, #vAdj do - local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, vAdj[i], GDB_ID.ROOT) + local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, FData.nFacInd, vAdj[i], GDB_ID.ROOT) if bAdj and dAng < 0 and 180 + dAng > 90.1 then local rfFac2, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, vAdj[i], GDB_ID.ROOT) _, tvtNx[2] = EgtSurfTmFacetCenter( Proc.Id, vAdj[i], GDB_ID.ROOT) tDimAndRef[2] = { dH2, dV2, rfFac2} local ptPs = ( ptP1 + ptP2) / 2 - local bOk, sWarn2 = MachineByMill( Proc, tvtNx, nFacInd, vAdj[i], ptPs, tDimAndRef, - EgtIf( ( Proc.Fct == 3 and bIsU), 0, 2), nUseRoughTool, dAng, sPocketing, sTuuidPk, dFacElev) + local bOk, sWarn2 = MachineByMill( Proc, tvtNx, FData.nFacInd, vAdj[i], ptPs, tDimAndRef, + EgtIf( ( Proc.Fct == 3 and bIsU), 0, 2), nUseRoughTool, dAng, sPocketing, sTuuidPk, FData.dFacElev) if not bOk then return bOk, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) end @@ -4984,17 +4996,17 @@ local function MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFa end -- se abilitato dal parametro Q inserisco foro sullo spigolo if Q_BORE_ON_CORNER == 1 then - local bOk, sWarn2 = MakeDrillOnCorner( Proc, nFacInd, dDiamTool) + local bOk, sWarn2 = MakeDrillOnCorner( Proc, FData.nFacInd, dDiamTool) if not bOk then return false, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) -- altrimenti se abilitato dal parametro Q inserisco percorso di pulitura elseif Q_BORE_ON_CORNER == 2 then - local bOk, sWarn2 = MakeSharpCleanCorner( Proc, nFacInd, dDiamTool) + local bOk, sWarn2 = MakeSharpCleanCorner( Proc, FData.nFacInd, dDiamTool) if not bOk then return false, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) -- altrimenti se abilitato dal parametro Q inserisco pulitura spigoli o contorno con fresa più piccola elseif Q_CONTOUR_SMALL_TOOL > 0 then - local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown) + local bOk, sWarn2 = MakeRoundCleanCornerOrContour( Proc, FData.nFacInd, dDiamTool, Q_CONTOUR_SMALL_TOOL, bMillDown) if not bOk then return false, sWarn2 end sWarn = FormatWarning( sWarn, sWarn2) end @@ -5012,29 +5024,27 @@ local function MakeTwoFaces( Proc, bSinglePart, bPrevBhSideMill) end -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - if not nFacInd or nFacInd < 0 then + local FData = GetFacetsData( Proc.Id) + if not FData.nFacInd or FData.nFacInd < 0 then local sErr = 'Error : MakeTwoFaces could not find reference face' EgtOutLog( sErr) return false, sErr end - local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - local _, dH, _ = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia local bMakeBySideMill, _, bHeadDir, dMaxMat, dToolDiam = VerifyBHSideMill( Proc, bSinglePart, bPrevBhSideMill) if bPrevBhSideMill == nil then bPrevBhSideMill = bMakeBySideMill end - if bMakeBySideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then + if bMakeBySideMill and ( dMaxMat <= FData.dH + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo if _nChamfer < 2 then - local bOk, sErr = MakeBySideMill(Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dToolDiam, bHeadDir) + local bOk, sErr = MakeBySideMill( Proc, FData, dMaxMat, dToolDiam, bHeadDir) return bOk, sErr end -- altrimenti lavoro con svuotatura else - local bOk, sErr = MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev, dFacElev2) + local bOk, sErr = MakePocketingOrMilling( Proc, FData, bSinglePart) return bOk, sErr end @@ -5050,46 +5060,44 @@ local function MakeThreeFaces( Proc, bSinglePart, bPrevBhSideMill) end -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - if not nFacInd or nFacInd < 0 then + local FData = GetFacetsData( Proc.Id) + if not FData.nFacInd or FData.nFacInd < 0 then local sErr = 'Error : MakeThreeFaces could not find reference face' EgtOutLog( sErr) return false, sErr end - local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacInd, GDB_ID.ROOT) - local rfFac, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacInd, GDB_ID.ROOT) -- se fattibile con fresa BH di fianco e spessore utensile inferiore alla larghezza faccia local bMakeBySideMill, _, bHeadDir, dMaxMat, dToolDiam = VerifyBHSideMill( Proc, bSinglePart, bPrevBhSideMill) if bPrevBhSideMill == nil then bPrevBhSideMill = bMakeBySideMill end --if bMakeBySideMill and ( dMaxMat <= dV + 15 * GEO.EPS_SMALL) then - if bMakeBySideMill and ( dMaxMat <= dH + 15 * GEO.EPS_SMALL) then + if bMakeBySideMill and ( dMaxMat <= FData.dH + 15 * GEO.EPS_SMALL) then -- se smusso non è esclusivo if _nChamfer < 2 then - local bOk, sErr = MakeBySideMill(Proc, ptC, vtN, nFacInd, dMaxMat, dFacElev, dToolDiam, bHeadDir) + local bOk, sErr = MakeBySideMill( Proc, FData, dMaxMat, dToolDiam, bHeadDir) return bOk, sErr end -- altrimenti lavoro con svuotatura else local bSpecial3faces = false - local bBoxF = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, rfFac) + local bBoxF = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, FData.rfFac) - if dH * dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then + if FData.dH * FData.dV < 0.9 * ( bBoxF:getDimX() * bBoxF:getDimY()) then bSpecial3faces = true end -- se riconosciuta gestione special (limitata per ora alla feature 20) - if bSpecial3faces and Proc.Prc == 20 and nFacInd2 then + if bSpecial3faces and Proc.Prc == 20 and FData.nFacInd2 then -- se smusso non è esclusivo if _nChamfer < 2 then - local bOk, sErr = MakeSpecialThreeFaces( Proc) + local bOk, sErr = MakeSpecialThreeFaces( Proc, FData) return bOk, sErr end -- altrimenti lavorazione di svuotatura o contornatura else - local bOk, sErr = MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev, dFacElev2) + local bOk, sErr = MakePocketingOrMilling( Proc, FData, bSinglePart) return bOk, sErr end end @@ -5102,10 +5110,10 @@ local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill) local bClosedOrthoFaces local nBottomFace -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - local nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( Proc.Id, _nPartId) - if not nFacInd or nFacInd < 0 then - if nFacInd == -1 then - bClosedOrthoFaces = nFacInd2 + local FData = GetFacetsData( Proc.Id) + if not FData.nFacInd or FData.nFacInd < 0 then + if FData.nFacInd == -1 then + bClosedOrthoFaces = FData.isOrthoFaces else local sErr = 'Error : MakeMoreFaces could not find reference face' EgtOutLog( sErr) @@ -5116,19 +5124,19 @@ local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill) if Proc.Prc == 16 and Proc.Fct == 5 and not bClosedOrthoFaces then -- dalla copia della superfice, ciclo eliminando una faccia per volta per verificare se trova fessura for i = 1, Proc.Fct do - local nNewProc = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL + local nNewProcId = EgtCopyGlob( Proc.Id, _nAddGrpId) or GDB_ID.NULL -- elimino una faccia nBottomFace = i - 1 - if EgtSurfTmRemoveFacet( nNewProc, nBottomFace) then + if EgtSurfTmRemoveFacet( nNewProcId, nBottomFace) then -- recupero la faccia con il maggior numero di adiacenze e l'elevazione relativa - nFacInd, dFacElev, nFacInd2, dFacElev2 = BL.GetFaceWithMostAdj( nNewProc, _nPartId) - if not nFacInd or nFacInd < 0 then - if nFacInd == -1 then - bClosedOrthoFaces = nFacInd2 - EgtErase( nNewProc) + FData = GetFacetsData( nNewProcId) + if not FData.nFacInd or FData.nFacInd < 0 then + if FData.nFacInd == -1 then + bClosedOrthoFaces = FData.isOrthoFaces + EgtErase( nNewProcId) break else - EgtErase( nNewProc) + EgtErase( nNewProcId) local sErr = 'Error : MakeMoreFaces could not find reference face' EgtOutLog( sErr) return false, sErr @@ -5136,16 +5144,16 @@ local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill) end -- altrimenti esco else - EgtErase( nNewProc) + EgtErase( nNewProcId) break end end -- se riconosciuta fessura ricalcolo l'elevazione dalla faccia di fondo if bClosedOrthoFaces then - nFacInd = nBottomFace - -- rendo nulla la faccia opzionale perchè si tratta di una fessura - nFacInd2 = nil - dFacElev = BL.GetFaceElevation( Proc.Id, nFacInd) + local dFacElev = BL.GetFaceElevation( Proc.Id, nBottomFace) + FData = UpdateFacet1Data( Proc.Id, FData, nBottomFace, dFacElev) + -- rendo nulla la faccia opzionale perchè si tratta di una fessura + FData = UpdateFacet2Data( Proc.Id, FData, nil) bClosedOrthoFaces = false -- non setto come tunnel end end @@ -5168,14 +5176,14 @@ local function MakeMoreFaces( Proc, bSinglePart, bPrevBhSideMill) -- Se la svuotatura precedente non è stata fatta e chamfer non è mutuamente esclusivo provo con la sega-catena if bTryWithBlades and _nChamfer < 2 then -- verifico se posso farlo con la sega-catena - local bOk, sErr = MakeByChainsaw(Proc, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace) + local bOk, sErr = MakeByChainsaw( Proc, dDimMin, dDimMax, dDepth, vtOrtho, nLundIdFace) if not bOk then return false, sErr end end -- altrimenti non è una fessura else - local bOk, sErr = MakePocketingOrMilling( Proc, nFacInd, nFacInd2, bSinglePart, dFacElev, dFacElev2) + local bOk, sErr = MakePocketingOrMilling( Proc, FData, bSinglePart) return bOk, sErr, bPrevBhSideMill end