From 1236d196ba26ea16f9e48b8ffd690a52ffe8195f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 20 Jun 2023 09:35:25 +0200 Subject: [PATCH 01/43] - TestElleShape 3 e 4 spostati in WallLib - a DoubleCut aggiunto riconoscimento della sola L011 - in WallLib aggiunta funzione GetProcessAffectedFaces che restituisce le facce del grezzo interessate dalla feature - in WallExec aggiunte alle Proc informazioni sulle facce della feature - alcune modifiche iniziali per Mirror --- .gitignore | 1 + LuaLibs/WProcessDoubleCut.lua | 6 +++ LuaLibs/WProcessLapJoint.lua | 62 +------------------------- LuaLibs/WallExec.lua | 66 ++++++++++++++++++++++++++- LuaLibs/WallLib.lua | 84 +++++++++++++++++++++++++++++++++++ 5 files changed, 158 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index aece050..4789404 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ /bin/*.ini /bin/LuaLibs/*.lua /bin/Images/*.png +.vscode/settings.json diff --git a/LuaLibs/WProcessDoubleCut.lua b/LuaLibs/WProcessDoubleCut.lua index 92e2ac9..05a35e3 100644 --- a/LuaLibs/WProcessDoubleCut.lua +++ b/LuaLibs/WProcessDoubleCut.lua @@ -24,6 +24,12 @@ function WPDC.Identify( Proc) ( Proc.Grp == 0 and Proc.Prc == 12)) end +--------------------------------------------------------------------- +-- Riconoscimento della sola feature L011 +function WPDC.IdentifyStrict( Proc) + return ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 11 +end + --------------------------------------------------------------------- -- Classificazione della feature function WPDC.Classify( Proc, b3Raw) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 3df915d..294ed7d 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -348,64 +348,6 @@ function WPL.FlipClassify( Proc) return nFlip0, nFlip1 end ---------------------------------------------------------------------- -local function TestElleShape3( nIdGeom, nNumFacet) - -- valida solo nel caso di tre facce - if nNumFacet ~= 3 then return false end - -- determino se L con una faccia terminale o U con tre facce - local bIsL = true - for i = 1, 3 do - local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end - if nCount == 1 then - bIsL = false - break - end - end - return bIsL -end - ---------------------------------------------------------------------- -local function TestElleShape4( nIdGeom, nNumFacet) - -- valida solo nel caso di quattro facce - if nNumFacet ~= 4 then return false end - -- determino se L con due facce terminali o O - local nFac3Adj = 0 - local dMinArea3 = GEO.INFINITO * GEO.INFINITO - local dMaxArea2 = 0 - for i = 1, 4 do - local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end - local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( nIdGeom, i - 1, GDB_ID.ROOT) - local dArea = dH * dV - if nCount == 2 then - dMaxArea2 = max( dMaxArea2, dArea) - elseif nCount == 3 then - dMinArea3 = min( dMinArea3, dArea) - nFac3Adj = nFac3Adj + 1 - end - end - if nFac3Adj ~= 2 then return false end - -- verifico se L profonda oppure lunga - if dMinArea3 < dMaxArea2 then - return 1 - else - return 2 - end -end - --------------------------------------------------------------------- local function GetOtherRegions( nPartId) local vOthers = {} @@ -2104,12 +2046,12 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) dDiam = 2 * dDiam end -- se forma ad L - local bIsL = ( Proc.Fct == 2 or TestElleShape3( Proc.Id, Proc.Fct) or TestElleShape4( Proc.Id, Proc.Fct) == 2) + local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2) if bIsL then dDiam = 2 * dDiam end -- se forma ad U - local bIsU = ( Proc.Fct == 3 and not TestElleShape3( Proc.Id, Proc.Fct)) + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) if bIsU then local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) -- prendo la linea di base diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 839fb75..6c80c5c 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -179,7 +179,17 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc.CutId = nCutId Proc.TaskId = nTaskId Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) - if Proc.Box and not Proc.Box:isEmpty() then + + -- recupero l'elenco delle facce della parte interessate dalla feature + Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc, PartId) + + -- recupero informazioni sulle facce della feature + Proc.Face = {} + for i = 1, Proc.Fct do + Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ), Elevation = WL.GetFaceElevation( Proc.Id, i - 1, PartId)} + end + + if Proc.Box and not Proc.Box:isEmpty() then table.insert( vProc, Proc) -- se foro if Drill.Identify( Proc) then @@ -580,6 +590,57 @@ local function SortMachinings( nPhase, PrevMch, nPartId) return PrevMch end +function VerifyLapJointMirrored( Proc, vProc, nPartId, b3Raw) + -- verifico se la geometria master è lavorabile in doppio (se la feature attuale è dal lato master) + local bIsThroughL = ( Proc.Fct == 2 and ( Proc.AffectedFaces == { true, true, false, false, true, true} or Proc.AffectedFaces == { true, false, false, true, true, true})) + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) + local bAllowDifferentZ = false + -- 2 lati a L, passante + if bIsThroughL then + bAllowDifferentZ = true + -- 3 lati a U, passante + elseif bIsU then + -- sul fianco, parallela a X + if Proc.AffectedFaces == { false, true, false, false, true, true} or Proc.AffectedFaces == { false, false, false, true, true, true} then + bAllowDifferentZ = true + -- sopra + elseif Proc.AffectedFaces == { true, false, false, false, true, true} then + + -- sul fianco, parallela a Z + elseif Proc.AffectedFaces == { true, true, true, false, false, false} then + + end + + -- 3 lati a L, non passante + elseif Proc.Fct == 3 then + + -- 4 lati + elseif Proc.Fct == 4 then + + -- 5 lati, tasca standard + elseif Proc.Fct == 5 then + + end + -- se la condizione sopra è vera, verifico se esistono una o più altre features specchiate + + -- se le condizioni sopra sono vere, lo segno nelle proprietà delle feature +end + +------------------------------------------------------------------------------------------------------------- +-- Cerca in vProc la presenza di feature da lavorare in doppio. +local function SetMirroredFeatures( vProc, nPartId, b3Raw) + for i = 1, #vProc do + local Proc = vProc[i] + if Proc.Flg ~= 0 then + -- Proc.Double -> 2: specchiatura in Y + -- Proc.MirrorId -> Id della feature mirrorata + if ( ( LapJoint.Identify and Proc.Prc ~= 20) or DoubleCut.IdentifyStrict( Proc)) and true then -- aggiungere dipendenza da costante WallData!! + VerifyLapJointMirrored( Proc, vProc, nPartId, b3Raw) + end + end + end +end + ------------------------------------------------------------------------------------------------------------- function WallExec.ProcessFeatures() -- errori e stato @@ -611,6 +672,9 @@ function WallExec.ProcessFeatures() if WD.FindFeaturesInDouble then WD.FindFeaturesInDouble( vProc, b3Raw) end + + SetMirroredFeatures( vProc, nPartId, b3Raw) + -- debug if EgtGetDebugLevel() >= 1 then PrintFeatures( vProc) diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index e19d316..0a04d4d 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -316,5 +316,89 @@ function WallLib.GetNearestOrthoOpposite( vtRef, vtNorm) return nil end +--------------------------------------------------------------------- +function WallLib.TestElleShape3( nIdGeom, nNumFacet) + -- valida solo nel caso di tre facce + if nNumFacet ~= 3 then return false end + -- determino se L con una faccia terminale o U con tre facce + local bIsL = true + for i = 1, 3 do + local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] + -- le conto + local nCount = 0 + for j = 1, #vFacAdj do + if vFacAdj[j] >= 0 then + nCount = nCount + 1 + end + end + if nCount == 1 then + bIsL = false + break + end + end + return bIsL +end + +--------------------------------------------------------------------- +function WallLib.TestElleShape4( nIdGeom, nNumFacet) + -- valida solo nel caso di quattro facce + if nNumFacet ~= 4 then return false end + -- determino se L con due facce terminali o O + local nFac3Adj = 0 + local dMinArea3 = GEO.INFINITO * GEO.INFINITO + local dMaxArea2 = 0 + for i = 1, 4 do + local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] + -- le conto + local nCount = 0 + for j = 1, #vFacAdj do + if vFacAdj[j] >= 0 then + nCount = nCount + 1 + end + end + local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( nIdGeom, i - 1, GDB_ID.ROOT) + local dArea = dH * dV + if nCount == 2 then + dMaxArea2 = max( dMaxArea2, dArea) + elseif nCount == 3 then + dMinArea3 = min( dMinArea3, dArea) + nFac3Adj = nFac3Adj + 1 + end + end + if nFac3Adj ~= 2 then return false end + -- verifico se L profonda oppure lunga + if dMinArea3 < dMaxArea2 then + return 1 + else + return 2 + end +end + +------------------------------------------------------------------------------------------------------------- +-- restituisce le facce del grezzo interessate dalla feature Proc +function WallLib.GetProcessAffectedFaces( Proc, nPartId) + local b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD) + local vtFacesAffected = { Bottom = false, Back = false, Top = false, Front = false, Left = false, Right = false} + if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Bottom = true + end + if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Back = true + end + if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Top = true + end + if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Front = true + end + if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Left = true + end + if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Right = true + end + return vtFacesAffected +end + ------------------------------------------------------------------------------------------------------------- return WallLib From 5bb7fdd63424f1399e4c3ddf94f25ab8b28dd503 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 28 Jun 2023 11:32:48 +0200 Subject: [PATCH 02/43] - aggiunta libreria WFeatureTopology per il riconoscimento topologico delle feature (da completare) - spostate alcune funzioni da FreeContour a WallLib --- .gitignore | 2 + LuaLibs/WFeatureTopology.lua | 130 ++++++++++++++++++++++++++++++++ LuaLibs/WProcessFreeContour.lua | 92 +--------------------- LuaLibs/WallLib.lua | 26 +++++++ bin/Images/.placeholder | 0 bin/LuaLibs/.placeholder | 0 6 files changed, 162 insertions(+), 88 deletions(-) create mode 100644 LuaLibs/WFeatureTopology.lua delete mode 100644 bin/Images/.placeholder delete mode 100644 bin/LuaLibs/.placeholder diff --git a/.gitignore b/.gitignore index 4789404..362a109 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ /bin/LuaLibs/*.lua /bin/Images/*.png .vscode/settings.json +bin/LuaLibs/.placeholder +bin/Images/.placeholder diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua new file mode 100644 index 0000000..fb33173 --- /dev/null +++ b/LuaLibs/WFeatureTopology.lua @@ -0,0 +1,130 @@ +-- WFeatureTopology.lua by Egaltech s.r.l. 2023/06/23 +-- Libreria per classificazione topologica feature pareti + +-- Tabella per definizione modulo +local WFeatureTopology = {} + +-- Include +require( 'EgtBase') + +EgtOutLog( ' WFeatureTopology started', 1) + +--------------------------------------------------------------------- +local function GetAdjacencyMatrix(Proc ) + local vAdj = {} + for i = 1, Proc.Fct do + for j = 1, Proc.Fct do + if i ~= j then + vAdj[i][j] = 0 + else + _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i, j, GDB_ID.ROOT) + end + j = j + 1 + end + i = i + 1 + end + return vAdj +end + +--------------------------------------------------------------------- +local function AreAllAnglesConcaveOrRight( Proc) + local vAdj = GetAdjacencyMatrix( Proc) + local bAllConcave, bAllRight = true, true + for i = 1, Proc.Fct do + for j = 1, Proc.Fct do + if vAdj[i][j] and vAdj[i][j] > 0 then + bAllConcave = false + bAllRight = false + break + elseif vAdj[i][j] and vAdj[i][j] + 90 > GEO.EPS_SMALL then + bAllRight = false + end + end + end + return bAllConcave, bAllRight +end + +--------------------------------------------------------------------- +local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, nNumberOfFaces) + -- feature passante o cieca + local sThrough = '_' + if bIsThrough ~= nil then EgtIf( bIsThrough, 'Through', 'Blind') end + -- tutti gli angoli della feature sono retti oppure no + local sAllRightAngles = '_' + if bAllRightAngles ~= nil then EgtIf( bAllRightAngles, 'RightAngles', 'NotRightAngles') end + -- tutte le dimensioni della feature sono parallele agli assi principali del pezzo oppure no + local sParallel = '_' + if bIsParallel ~= nil then EgtIf( bIsParallel, 'Parallel', 'NotParallel') end + + local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. nNumberOfFaces + return sLongName +end + +--------------------------------------------------------------------- +function WFeatureTopology.Bevel( Proc) + local sFamily + local bIsThrough + local bAllRightAngles + local bIsParallel + local sLongName = '' + + local bAllAnglesConcave + bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) + if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then + sFamily = 'Bevel' + bIsThrough = true + elseif Proc.Fct == 2 and bAllAnglesConcave and ( not IsAnyDimensionLongAsPart( Proc) or IsOneFaceTriangular( Proc)) then + sFamily = 'Bevel' + bIsThrough = false + end + bIsParallel = IsFeatureParallelToPart( Proc, sFamily) + + if sFamily then + sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) + return sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName + else + return nil + end +end + +function WFeatureTopology.ClassifyTopology( Proc) + local sTopologicalName + if Proc.Fct == 1 then + if IsAnyDimensionLongAsPart( Proc) then + sTopologicalName = 'Bevel_Through___Parallel_1' + end + elseif Proc.Fct == 2 then + if vAdj[1][1] and abs( vAdj[1][1] - 90) < GEO.EPS_SMALL then + + end + end +end + + + + + + + + + + + + + + + + + + + + + + + + + + + +------------------------------------------------------------------------------------------------------------- +return WFeatureTopology \ No newline at end of file diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index 52e3dc8..cd6bf6d 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -20,6 +20,7 @@ -- 2023/04/17 Lavorazione CleanCorner sempre forzata con lato di lavoro in centro. -- 2023/05/25 Funzioni EgtAddMachining sostituite da WM.AddMachining in modo da trascrivere le priorità da btl alle lavorazioni. -- 2023/06/06 Aggiunta gestione lavorazione per lamatura speciale affondata con Tool_ID specifico. +-- 2023/06/26 Funzione Is3EdgesApprox spostata in WallLib. -- Tabella per definizione modulo local WPF = {} @@ -148,64 +149,6 @@ function WPF.FlipClassify( Proc, b3Raw) return nFlip0, nFlip1 end ---------------------------------------------------------------------- -local function TestElleShape3( nIdGeom, nNumFacet) - -- valida solo nel caso di tre facce - if nNumFacet ~= 3 then return false end - -- determino se L con una faccia terminale o U con tre facce - local bIsL = true - for i = 1, 3 do - local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end - if nCount == 1 then - bIsL = false - break - end - end - return bIsL -end - ---------------------------------------------------------------------- -local function TestElleShape4( nIdGeom, nNumFacet) - -- valida solo nel caso di quattro facce - if nNumFacet ~= 4 then return false end - -- determino se L con due facce terminali o O - local nFac3Adj = 0 - local dMinArea3 = GEO.INFINITO * GEO.INFINITO - local dMaxArea2 = 0 - for i = 1, 4 do - local vFacAdj = EgtSurfTmFacetAdjacencies( nIdGeom, i - 1)[1] - -- le conto - local nCount = 0 - for j = 1, #vFacAdj do - if vFacAdj[j] >= 0 then - nCount = nCount + 1 - end - end - local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( nIdGeom, i - 1, GDB_ID.ROOT) - local dArea = dH * dV - if nCount == 2 then - dMaxArea2 = max( dMaxArea2, dArea) - elseif nCount == 3 then - dMinArea3 = min( dMinArea3, dArea) - nFac3Adj = nFac3Adj + 1 - end - end - if nFac3Adj ~= 2 then return false end - -- verifico se L profonda oppure lunga - if dMinArea3 < dMaxArea2 then - return 1 - else - return 2 - end -end - --------------------------------------------------------------------- local function VerifyCornerType( Proc) -- Verifico il tipo di lavorazione su angolo : @@ -1243,33 +1186,6 @@ local function GetMaxDepth( vtNz, dMillDiam, dDiamTh, dMaxDepth, dFreeLen) end end ---------------------------------------------------------------------- --- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce -local function Is3EdgesApprox( Proc, nFacet, nAddGrpId) - local bResult = false - local nContourId = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) - EgtMergeCurvesInCurveCompo( nContourId) - -- recupero il numero effettivo di lati - local _, nEntityCount = EgtCurveDomain( nContourId) - local nEdges = nEntityCount - if nContourId then - if nEntityCount and nEntityCount == 3 then - bResult = true - -- rimuovo i lati molto corti dal conteggio totale - elseif nEntityCount then - for i = 1, nEntityCount do - local dLength = EgtCurveCompoLength( nContourId, i - 1) - if dLength < 15 then nEdges = nEdges - 1 end - end - end - if nEdges == 3 then bResult = true end - end - if bResult == true then - EgtOutLog( 'FreeContour : Face with ' .. tointeger( nEntityCount) .. ' edges skipped (approx 3 edges)') - end - return bResult -end - --------------------------------------------------------------------- local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAddGrpId) -- flag per fresature non passanti @@ -1292,7 +1208,7 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd end -- verifico se la facce hanno alcuni lati molto corti e possono quindi essere approssimate a 3 lati for currentFace = 1, #vFace do - if Is3EdgesApprox( Proc, vFace[currentFace].Fac, nAddGrpId) then + if WL.Is3EdgesApprox( Proc, vFace[currentFace].Fac, nAddGrpId) then vFace[currentFace].Is3EdgesApprox = true end end @@ -2460,9 +2376,9 @@ local function MakeByPocket( Proc, nRawId, b3Raw) local nAddGrpId = WL.GetAddGroup( Proc.PartId) local nNewProc, nNumFacet = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet) -- se ho forma a L - local bIsL = ( nNumFacet == 2 or TestElleShape3( nNewProc, nNumFacet) or TestElleShape4( nNewProc, nNumFacet) == 2) + local bIsL = ( nNumFacet == 2 or WL.TestElleShape3( nNewProc, nNumFacet) or WL.TestElleShape4( nNewProc, nNumFacet) == 2) -- verifico se U - local bIsU = ( nNumFacet == 3 and not TestElleShape3( nNewProc, nNumFacet)) + local bIsU = ( nNumFacet == 3 and not WL.TestElleShape3( nNewProc, nNumFacet)) local dMiddleFacetLength = 0 if bIsU then local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( nNewProc, 1, GDB_ID.ROOT) diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index 0a04d4d..e456e33 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -1,5 +1,6 @@ -- WallLib.lua by Egaltech s.r.l. 2022/04/04 -- Libreria globale per Pareti +-- 2023/06/26 Spostata qui Is3EdgesApprox da FreeContour. Ora cerca autonomamente il gruppo se non viene passato. -- Tabella per definizione modulo local WallLib = {} @@ -374,6 +375,31 @@ function WallLib.TestElleShape4( nIdGeom, nNumFacet) end end +--------------------------------------------------------------------- +-- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce +function WallLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId) + nAddGrpId = nAddGrpId or WallLib.GetAddGroup( Proc.PartId) + local bResult = false + local nContourId = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) + EgtMergeCurvesInCurveCompo( nContourId) + -- recupero il numero effettivo di lati + local _, nEntityCount = EgtCurveDomain( nContourId) + local nEdges = nEntityCount + if nContourId then + if nEntityCount and nEntityCount == 3 then + bResult = true + -- rimuovo i lati molto corti dal conteggio totale + elseif nEntityCount then + for i = 1, nEntityCount do + local dLength = EgtCurveCompoLength( nContourId, i - 1) + if dLength < 15 then nEdges = nEdges - 1 end + end + end + if nEdges == 3 then bResult = true end + end + return bResult +end + ------------------------------------------------------------------------------------------------------------- -- restituisce le facce del grezzo interessate dalla feature Proc function WallLib.GetProcessAffectedFaces( Proc, nPartId) diff --git a/bin/Images/.placeholder b/bin/Images/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/bin/LuaLibs/.placeholder b/bin/LuaLibs/.placeholder deleted file mode 100644 index e69de29..0000000 From 6550ddd45655884e8f071a5ad9729aa25110dbd9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 30 Jun 2023 09:54:33 +0200 Subject: [PATCH 03/43] altre aggiunte a WFeatureTopology --- LuaLibs/WFeatureTopology.lua | 92 ++++++++++++++++++++---------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index fb33173..be52782 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -7,6 +7,9 @@ local WFeatureTopology = {} -- Include require( 'EgtBase') +-- Carico le librerie +local WL = require( 'WallLib') + EgtOutLog( ' WFeatureTopology started', 1) --------------------------------------------------------------------- @@ -42,6 +45,51 @@ local function AreAllAnglesConcaveOrRight( Proc) end end return bAllConcave, bAllRight +end + +--------------------------------------------------------------------- +local function IsAnyDimensionLongAsPart( Proc ) + local bResult = false + local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD) + if Proc.Box:getDimX() > b3Solid:getDimX() - 10 * GEO.EPS_SMALL or + Proc.Box:getDimY() > b3Solid:getDimY() - 10 * GEO.EPS_SMALL or + Proc.Box:getDimZ() > b3Solid:getDimZ() - 10 * GEO.EPS_SMALL then + bResult = true + end +end + +--------------------------------------------------------------------- +local function GetTriangularFaces( Proc) + local vTriangularFaces = {} + for i = 1, Proc.Fct do + if WL.Is3EdgesApprox( Proc, i - 1) then + table.insert( vTriangularFaces, i - 1) + end + end + return vTriangularFaces +end + +--------------------------------------------------------------------- +local function IsFeatureParallelToPart( Proc, sFamily) + if sFamily == 'Bevel' then + local _, vTriangularFaces = IsAnyFaceTriangular( Proc) + for i = 0, Proc.Fct - 1 do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT) + for j = 0, #vTriangularFaces do + if i == vTriangularFaces[j] then + if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then + + end + else + + end + end + end + end + + + + end --------------------------------------------------------------------- @@ -68,12 +116,15 @@ function WFeatureTopology.Bevel( Proc) local bIsParallel local sLongName = '' + -- SE NON HA TUTTE LE FACCE PIANE RITORNARE NIL!! local bAllAnglesConcave bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) + local vTriangularFaces = GetTriangularFaces( Proc) + local bIsAnyFaceTriangular = #vTriangularFaces > 0 if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then sFamily = 'Bevel' bIsThrough = true - elseif Proc.Fct == 2 and bAllAnglesConcave and ( not IsAnyDimensionLongAsPart( Proc) or IsOneFaceTriangular( Proc)) then + elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then sFamily = 'Bevel' bIsThrough = false end @@ -86,45 +137,6 @@ function WFeatureTopology.Bevel( Proc) return nil end end - -function WFeatureTopology.ClassifyTopology( Proc) - local sTopologicalName - if Proc.Fct == 1 then - if IsAnyDimensionLongAsPart( Proc) then - sTopologicalName = 'Bevel_Through___Parallel_1' - end - elseif Proc.Fct == 2 then - if vAdj[1][1] and abs( vAdj[1][1] - 90) < GEO.EPS_SMALL then - - end - end -end - - - - - - - - - - - - - - - - - - - - - - - - - - ------------------------------------------------------------------------------------------------------------- return WFeatureTopology \ No newline at end of file From 4e079f6708868d89c7609da5d17554717b7e0015 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 4 Jul 2023 11:22:03 +0200 Subject: [PATCH 04/43] completamento parziale della funzione per recuperare le facce parallele alla parte --- LuaLibs/WFeatureTopology.lua | 45 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index be52782..cf12741 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -70,26 +70,38 @@ local function GetTriangularFaces( Proc) end --------------------------------------------------------------------- -local function IsFeatureParallelToPart( Proc, sFamily) - if sFamily == 'Bevel' then - local _, vTriangularFaces = IsAnyFaceTriangular( Proc) - for i = 0, Proc.Fct - 1 do - local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT) +local function GetFacesParallelToPart( Proc, sFamily) + local vIsFaceParallel = {} + for i = 0, Proc.Fct - 1 do + local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT) + if sFamily == 'Bevel' then + local vTriangularFaces = GetTriangularFaces( Proc) + local bIsTriangularFace = false + -- verifico se la faccia è triangolare for j = 0, #vTriangularFaces do if i == vTriangularFaces[j] then - if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then - - end - else - + bIsTriangularFace = true end end + -- se faccia triangolare deve avere la normale parallela ad una direzione principale + if bIsTriangularFace then + if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then + vIsFaceParallel[i] = true + end + -- altrimenti deve avere una componente della normale nulla + else + if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then + vIsFaceParallel[i] = true + end + end + else + -- la normale deve essere parallela alla direzione principale + if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then + vIsFaceParallel[i] = true + end end end - - - - + return vIsFaceParallel end --------------------------------------------------------------------- @@ -128,7 +140,10 @@ function WFeatureTopology.Bevel( Proc) sFamily = 'Bevel' bIsThrough = false end - bIsParallel = IsFeatureParallelToPart( Proc, sFamily) + local vIsFaceParallel = GetFacesParallelToPart( Proc, sFamily) + for i = 1, #vIsFaceParallel do + + end if sFamily then sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) From be49385bb03e22a66d3c9e4ebd2cd6f8eb7d9019 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 5 Jul 2023 18:38:17 +0200 Subject: [PATCH 05/43] - riconoscimento bevel e rabbet funzionanti; da testare --- LuaLibs/WFeatureTopology.lua | 63 ++++++++++++++++++++---------------- LuaLibs/WallExec.lua | 17 ++++++++++ 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index cf12741..a15665f 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -16,11 +16,12 @@ EgtOutLog( ' WFeatureTopology started', 1) local function GetAdjacencyMatrix(Proc ) local vAdj = {} for i = 1, Proc.Fct do + vAdj[i] = {} for j = 1, Proc.Fct do - if i ~= j then + if i == j then vAdj[i][j] = 0 else - _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i, j, GDB_ID.ROOT) + _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT) end j = j + 1 end @@ -31,6 +32,7 @@ end --------------------------------------------------------------------- local function AreAllAnglesConcaveOrRight( Proc) + if Proc.Fct < 2 then return nil end local vAdj = GetAdjacencyMatrix( Proc) local bAllConcave, bAllRight = true, true for i = 1, Proc.Fct do @@ -39,7 +41,7 @@ local function AreAllAnglesConcaveOrRight( Proc) bAllConcave = false bAllRight = false break - elseif vAdj[i][j] and vAdj[i][j] + 90 > GEO.EPS_SMALL then + elseif vAdj[i][j] and vAdj[i][j] ~= 0 and vAdj[i][j] + 90 > GEO.EPS_SMALL then bAllRight = false end end @@ -51,11 +53,12 @@ end local function IsAnyDimensionLongAsPart( Proc ) local bResult = false local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD) - if Proc.Box:getDimX() > b3Solid:getDimX() - 10 * GEO.EPS_SMALL or - Proc.Box:getDimY() > b3Solid:getDimY() - 10 * GEO.EPS_SMALL or - Proc.Box:getDimZ() > b3Solid:getDimZ() - 10 * GEO.EPS_SMALL then + if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or + Proc.Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or + Proc.Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then bResult = true end + return bResult end --------------------------------------------------------------------- @@ -71,14 +74,14 @@ end --------------------------------------------------------------------- local function GetFacesParallelToPart( Proc, sFamily) - local vIsFaceParallel = {} + local vFacesParallelToPart = {} for i = 0, Proc.Fct - 1 do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT) if sFamily == 'Bevel' then local vTriangularFaces = GetTriangularFaces( Proc) local bIsTriangularFace = false -- verifico se la faccia è triangolare - for j = 0, #vTriangularFaces do + for j = 1, #vTriangularFaces do if i == vTriangularFaces[j] then bIsTriangularFace = true end @@ -86,42 +89,43 @@ local function GetFacesParallelToPart( Proc, sFamily) -- se faccia triangolare deve avere la normale parallela ad una direzione principale if bIsTriangularFace then if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then - vIsFaceParallel[i] = true + table.insert( vFacesParallelToPart, i) end -- altrimenti deve avere una componente della normale nulla else - if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then - vIsFaceParallel[i] = true + if vtN:getX() < 10 * GEO.EPS_SMALL or vtN:getY() < 10 * GEO.EPS_SMALL or vtN:getZ() < 10 * GEO.EPS_SMALL then + table.insert( vFacesParallelToPart, i) end end else - -- la normale deve essere parallela alla direzione principale - if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then - vIsFaceParallel[i] = true + -- la normale deve essere parallela ad una direzione principale + if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then + table.insert( vFacesParallelToPart, i) end end end - return vIsFaceParallel + return vFacesParallelToPart end --------------------------------------------------------------------- local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, nNumberOfFaces) -- feature passante o cieca local sThrough = '_' - if bIsThrough ~= nil then EgtIf( bIsThrough, 'Through', 'Blind') end + if bIsThrough ~= nil then sThrough = EgtIf( bIsThrough, 'Through', 'Blind') end -- tutti gli angoli della feature sono retti oppure no local sAllRightAngles = '_' - if bAllRightAngles ~= nil then EgtIf( bAllRightAngles, 'RightAngles', 'NotRightAngles') end + if bAllRightAngles ~= nil then sAllRightAngles = EgtIf( bAllRightAngles, 'RightAngles', 'NotRightAngles') end -- tutte le dimensioni della feature sono parallele agli assi principali del pezzo oppure no local sParallel = '_' - if bIsParallel ~= nil then EgtIf( bIsParallel, 'Parallel', 'NotParallel') end + if bIsParallel ~= nil then sParallel = EgtIf( bIsParallel, 'Parallel', 'NotParallel') end - local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. nNumberOfFaces + local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. '-' .. nNumberOfFaces return sLongName end --------------------------------------------------------------------- -function WFeatureTopology.Bevel( Proc) +function WFeatureTopology.Classify( Proc) + local bRecognized = false local sFamily local bIsThrough local bAllRightAngles @@ -133,24 +137,27 @@ function WFeatureTopology.Bevel( Proc) bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) local vTriangularFaces = GetTriangularFaces( Proc) local bIsAnyFaceTriangular = #vTriangularFaces > 0 - if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then + local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) + if Proc.Fct == 1 and bIsAnyDimensionLongAsPart then sFamily = 'Bevel' bIsThrough = true elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then sFamily = 'Bevel' bIsThrough = false + elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyDimensionLongAsPart then + sFamily = 'Rabbet' + bIsThrough = true end - local vIsFaceParallel = GetFacesParallelToPart( Proc, sFamily) - for i = 1, #vIsFaceParallel do - - end + local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily) + bIsParallel = ( #vFacesParallelToPart == Proc.Fct) if sFamily then sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) - return sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName - else - return nil + Proc.Topology, Proc.IsThrough, Proc.AllRightAngles, Proc.IsParallel, Proc.TopologyLongName = sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName + bRecognized = true end + + return bRecognized end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 56323d1..aba7054 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -23,6 +23,7 @@ if WALL and WALL.NESTINGCORNERBL then WD.NESTING_CORNER = 'BL' end -- Carico le librerie _G.package.loaded.WMachiningLib = nil _G.package.loaded.WallLib = nil +_G.package.loaded.WFeatureTopology = nil _G.package.loaded.WProcessCut = nil _G.package.loaded.WProcessDoubleCut = nil _G.package.loaded.WProcessSawCut = nil @@ -36,6 +37,7 @@ _G.package.loaded.WProcessFreeContour = nil _G.package.loaded.WProcessVariant = nil local WM = require( 'WMachiningLib') local WL = require( 'WallLib') +local Topology = require( 'WFeatureTopology') local Cut = require( 'WProcessCut') local DoubleCut = require( 'WProcessDoubleCut') local SawCut = require( 'WProcessSawCut') @@ -289,6 +291,19 @@ local function ClassifyFeatures( vProc, b3Raw) end end +------------------------------------------------------------------------------------------------------------- +local function ClassifyTopology( vProc) + local nRecognized = 0 + for i = 1, #vProc do + local Proc = vProc[i] + if Topology.Classify( Proc) then + nRecognized = nRecognized + 1 + end + end + + return nRecognized +end + ------------------------------------------------------------------------------------------------------------- local function PrintFeatures( vProc) EgtOutLog( ' *** Feature List ***') @@ -699,6 +714,8 @@ function WallExec.ProcessFeatures() local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw) vProc = EgtJoinTables( vProc, vPartProc) end + -- classifico topologicamente le feature + ClassifyTopology( vProc) -- classifico le feature ClassifyFeatures( vProc, b3Raw) -- Eventuale determinazione delle feature lavorabili in parallelo (implementata nella configurazione macchina) From b0abe6d088a9633a3155f51227a5ee44a3d8ff4b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 6 Jul 2023 15:32:40 +0200 Subject: [PATCH 06/43] - alcune correzioni a Topology - aggiunto riconoscimento topologie fino a 5 lati (da testare) --- LuaLibs/WFeatureTopology.lua | 69 +++++++++++++++++++++++++++++++----- LuaLibs/WallExec.lua | 4 +-- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index a15665f..2d8dad1 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -13,7 +13,7 @@ local WL = require( 'WallLib') EgtOutLog( ' WFeatureTopology started', 1) --------------------------------------------------------------------- -local function GetAdjacencyMatrix(Proc ) +local function GetAdjacencyMatrix( Proc) local vAdj = {} for i = 1, Proc.Fct do vAdj[i] = {} @@ -22,6 +22,7 @@ local function GetAdjacencyMatrix(Proc ) vAdj[i][j] = 0 else _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT) + if not vAdj[i][j] then vAdj[i][j] = 0 end end j = j + 1 end @@ -30,13 +31,32 @@ local function GetAdjacencyMatrix(Proc ) return vAdj end +--------------------------------------------------------------------- +-- restituisce gli id delle facce di Proc che hanno il numero di adiacenze nAdj +local function GetFacesWithGivenAdjacencyNumber( Proc, nAdj) + local vAdj = GetAdjacencyMatrix( Proc) + local vFacesWithGivenAdj = {} + for i = 1, Proc.Fct do + local nAdjCount = 0 + for j = 1, Proc.Fct do + if vAdj[i][j] and vAdj[i][j] ~= 0 then + nAdjCount = nAdjCount + 1 + end + end + if nAdjCount == nAdj then + table.insert( vFacesWithGivenAdj, i - 1) + end + end + return vFacesWithGivenAdj +end + --------------------------------------------------------------------- local function AreAllAnglesConcaveOrRight( Proc) - if Proc.Fct < 2 then return nil end local vAdj = GetAdjacencyMatrix( Proc) local bAllConcave, bAllRight = true, true for i = 1, Proc.Fct do for j = 1, Proc.Fct do + -- se trovo un angolo convesso restituisco falso e esco subito if vAdj[i][j] and vAdj[i][j] > 0 then bAllConcave = false bAllRight = false @@ -46,11 +66,16 @@ local function AreAllAnglesConcaveOrRight( Proc) end end end - return bAllConcave, bAllRight + -- se 1 faccia oppure 2 facce con angolo convesso non ha senso ritornare valori per bAllRight + if Proc.Fct < 2 or ( Proc.Fct == 2 and vAdj[1][2] > 0) then + return bAllConcave + else + return bAllConcave, bAllRight + end end --------------------------------------------------------------------- -local function IsAnyDimensionLongAsPart( Proc ) +local function IsAnyDimensionLongAsPart( Proc) local bResult = false local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD) if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or @@ -77,7 +102,7 @@ local function GetFacesParallelToPart( Proc, sFamily) local vFacesParallelToPart = {} for i = 0, Proc.Fct - 1 do local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT) - if sFamily == 'Bevel' then + if sFamily == 'Bevel' or sFamily == 'DoubleBevel' then local vTriangularFaces = GetTriangularFaces( Proc) local bIsTriangularFace = false -- verifico se la faccia è triangolare @@ -93,7 +118,7 @@ local function GetFacesParallelToPart( Proc, sFamily) end -- altrimenti deve avere una componente della normale nulla else - if vtN:getX() < 10 * GEO.EPS_SMALL or vtN:getY() < 10 * GEO.EPS_SMALL or vtN:getZ() < 10 * GEO.EPS_SMALL then + if abs( vtN:getX()) < 10 * GEO.EPS_SMALL or abs( vtN:getY()) < 10 * GEO.EPS_SMALL or abs( vtN:getZ()) < 10 * GEO.EPS_SMALL then table.insert( vFacesParallelToPart, i) end end @@ -136,17 +161,43 @@ function WFeatureTopology.Classify( Proc) local bAllAnglesConcave bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) local vTriangularFaces = GetTriangularFaces( Proc) - local bIsAnyFaceTriangular = #vTriangularFaces > 0 local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) - if Proc.Fct == 1 and bIsAnyDimensionLongAsPart then + local vFacesWithTwoAdj = GetFacesWithGivenAdjacencyNumber( Proc, 2) + local vFacesWithThreeAdj = GetFacesWithGivenAdjacencyNumber( Proc, 3) + local vFacesWithFourAdj = GetFacesWithGivenAdjacencyNumber( Proc, 4) + + if Proc.IsOutline then + sFamily = 'OUTLINE' + elseif Proc.Fct == 1 and bIsAnyDimensionLongAsPart then sFamily = 'Bevel' bIsThrough = true - elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then + elseif Proc.Fct == 2 and bAllAnglesConcave and #vTriangularFaces == 1 then sFamily = 'Bevel' bIsThrough = false elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyDimensionLongAsPart then sFamily = 'Rabbet' bIsThrough = true + elseif Proc.Fct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then + sFamily = 'DoubleBevel' + bIsThrough = true + elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 1 and #vTriangularFaces == 2 then + sFamily = 'Bevel' + bIsThrough = false + elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 1 and bIsAnyDimensionLongAsPart then + sFamily = 'Groove' + bIsThrough = true + elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 3 then + sFamily = 'Groove' + bIsThrough = false + elseif Proc.Fct == 4 and #vFacesWithThreeAdj == 2 then + sFamily = 'Groove' + bIsThrough = false + elseif Proc.Fct == 4 and #vFacesWithTwoAdj == 4 and bIsAnyDimensionLongAsPart then + sFamily = 'Tunnel' + bIsThrough = true + elseif Proc.Fct == 5 and #vFacesWithFourAdj == 1 then + sFamily = 'Tunnel' + bIsThrough = false end local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily) bIsParallel = ( #vFacesParallelToPart == Proc.Fct) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index aba7054..d058f36 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -309,9 +309,9 @@ local function PrintFeatures( vProc) EgtOutLog( ' *** Feature List ***') for i = 1, #vProc do local Proc = vProc[i] - local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s', + local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s TopoName=%s', Proc.PartId, Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, - Proc.Flg, Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box)) + Proc.Flg, Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box), Proc.TopologyLongName or '') EgtOutLog( sOut) end end From 3ca0ab1692ebc951f8a0f74c3fe66e1832efab8a Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 7 Jul 2023 18:07:11 +0200 Subject: [PATCH 07/43] - altri piccoli miglioramenti legati al riconoscimento topologia --- LuaLibs/WFeatureTopology.lua | 21 ++++++++++++------ LuaLibs/WallExec.lua | 2 +- LuaLibs/WallLib.lua | 42 ++++++++++++++++++++---------------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index 2d8dad1..0ae9bd1 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -61,7 +61,7 @@ local function AreAllAnglesConcaveOrRight( Proc) bAllConcave = false bAllRight = false break - elseif vAdj[i][j] and vAdj[i][j] ~= 0 and vAdj[i][j] + 90 > GEO.EPS_SMALL then + elseif vAdj[i][j] and vAdj[i][j] ~= 0 and vAdj[i][j] + 90 > 500 * GEO.EPS_ANG_SMALL then bAllRight = false end end @@ -77,7 +77,8 @@ end --------------------------------------------------------------------- local function IsAnyDimensionLongAsPart( Proc) local bResult = false - local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD) + local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') + local b3Solid = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or Proc.Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or Proc.Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then @@ -168,6 +169,8 @@ function WFeatureTopology.Classify( Proc) if Proc.IsOutline then sFamily = 'OUTLINE' + elseif Proc.Prc == 40 then + sFamily = 'DRILLING' elseif Proc.Fct == 1 and bIsAnyDimensionLongAsPart then sFamily = 'Bevel' bIsThrough = true @@ -189,23 +192,29 @@ function WFeatureTopology.Classify( Proc) elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 3 then sFamily = 'Groove' bIsThrough = false - elseif Proc.Fct == 4 and #vFacesWithThreeAdj == 2 then + elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesWithThreeAdj == 2 then sFamily = 'Groove' bIsThrough = false - elseif Proc.Fct == 4 and #vFacesWithTwoAdj == 4 and bIsAnyDimensionLongAsPart then + elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesWithTwoAdj == 4 and bIsAnyDimensionLongAsPart then sFamily = 'Tunnel' bIsThrough = true - elseif Proc.Fct == 5 and #vFacesWithFourAdj == 1 then + elseif Proc.Fct == 5 and bAllAnglesConcave and #vFacesWithFourAdj == 1 then sFamily = 'Tunnel' bIsThrough = false end local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily) bIsParallel = ( #vFacesParallelToPart == Proc.Fct) - if sFamily then + if sFamily == 'OUTLINE' or sFamily == 'DRILLING' then + Proc.Topology = sFamily + Proc.TopologyLongName = sFamily + elseif sFamily then sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) Proc.Topology, Proc.IsThrough, Proc.AllRightAngles, Proc.IsParallel, Proc.TopologyLongName = sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName bRecognized = true + else + Proc.Topology = 'OTHER' + Proc.TopologyLongName = 'OTHER' end return bRecognized diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index d947d7f..427674e 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -194,7 +194,7 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc.IsOutline = ( Proc.Prc == 251 or Proc.Prc == 252) -- recupero l'elenco delle facce della parte interessate dalla feature - Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc, PartId) + Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) -- recupero informazioni sulle facce della feature Proc.Face = {} diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index e456e33..f6945db 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -402,27 +402,31 @@ end ------------------------------------------------------------------------------------------------------------- -- restituisce le facce del grezzo interessate dalla feature Proc -function WallLib.GetProcessAffectedFaces( Proc, nPartId) - local b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD) +function WallLib.GetProcessAffectedFaces( Proc) + local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') + local b3Part = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) local vtFacesAffected = { Bottom = false, Back = false, Top = false, Front = false, Left = false, Right = false} - if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then - vtFacesAffected.Bottom = true - end - if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then - vtFacesAffected.Back = true - end - if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 10 * GEO.EPS_SMALL then - vtFacesAffected.Top = true - end - if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 10 * GEO.EPS_SMALL then - vtFacesAffected.Front = true - end - if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 10 * GEO.EPS_SMALL then - vtFacesAffected.Left = true - end - if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 10 * GEO.EPS_SMALL then - vtFacesAffected.Right = true + if Proc.Box and not Proc.Box:isEmpty() then + if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Bottom = true + end + if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Back = true + end + if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Top = true + end + if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Front = true + end + if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Left = true + end + if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Right = true + end end + return vtFacesAffected end From 5ee62cfee266616f2bb8c34e8acd310925b18c43 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 10 Jul 2023 09:51:08 +0200 Subject: [PATCH 08/43] commenti funzioni e piccoli fix --- LuaLibs/WFeatureTopology.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index 0ae9bd1..da012b4 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -13,6 +13,7 @@ local WL = require( 'WallLib') EgtOutLog( ' WFeatureTopology started', 1) --------------------------------------------------------------------- +-- restituisce la matrice delle adiacenze di Proc dove i e j sono le facce e a(ij) è l'angolo tra di esse; 0 se nessuna adiacenza local function GetAdjacencyMatrix( Proc) local vAdj = {} for i = 1, Proc.Fct do @@ -51,6 +52,7 @@ local function GetFacesWithGivenAdjacencyNumber( Proc, nAdj) end --------------------------------------------------------------------- +-- restituisce true se Proc ha tutti gli angoli concavi (bAllConcave) e, nei casi in cui ha senso, se questi sono esattamente 90 deg (bAllRight) local function AreAllAnglesConcaveOrRight( Proc) local vAdj = GetAdjacencyMatrix( Proc) local bAllConcave, bAllRight = true, true @@ -75,6 +77,7 @@ local function AreAllAnglesConcaveOrRight( Proc) end --------------------------------------------------------------------- +-- restituisce true se almeno una delle dimensioni della feature è maggiore o uguale ad una delle dimensioni principali del pezzo (tolleranza 1 mm) local function IsAnyDimensionLongAsPart( Proc) local bResult = false local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') @@ -88,6 +91,7 @@ local function IsAnyDimensionLongAsPart( Proc) end --------------------------------------------------------------------- +-- retituisce un vettore con gli indici (0 based) delle facce triangolari (o quasi) di Proc local function GetTriangularFaces( Proc) local vTriangularFaces = {} for i = 1, Proc.Fct do @@ -99,6 +103,7 @@ local function GetTriangularFaces( Proc) end --------------------------------------------------------------------- +-- restituisce un vettore contenente gli indici delle facce di Proc parallele ad una delle direzioni principali; il check varia in base alla famiglia topologica local function GetFacesParallelToPart( Proc, sFamily) local vFacesParallelToPart = {} for i = 0, Proc.Fct - 1 do @@ -134,6 +139,8 @@ local function GetFacesParallelToPart( Proc, sFamily) end --------------------------------------------------------------------- +-- restituisce una stringa con il nome esteso della topologia della feature +-- *famiglia-passante-angoli tutti concavi a 90deg-facce tutte parallele alle dimensioni principali-numero di facce* local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, nNumberOfFaces) -- feature passante o cieca local sThrough = '_' @@ -150,6 +157,7 @@ local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsPar end --------------------------------------------------------------------- +-- risonosce se Proc è una delle topologie standard e, in caso positivo, ne scrive le caratteristiche in campi specifici della Proc stessa restituendo true function WFeatureTopology.Classify( Proc) local bRecognized = false local sFamily @@ -159,6 +167,7 @@ function WFeatureTopology.Classify( Proc) local sLongName = '' -- SE NON HA TUTTE LE FACCE PIANE RITORNARE NIL!! + local bAllAnglesConcave bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) local vTriangularFaces = GetTriangularFaces( Proc) @@ -208,6 +217,7 @@ function WFeatureTopology.Classify( Proc) if sFamily == 'OUTLINE' or sFamily == 'DRILLING' then Proc.Topology = sFamily Proc.TopologyLongName = sFamily + bRecognized = true elseif sFamily then sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) Proc.Topology, Proc.IsThrough, Proc.AllRightAngles, Proc.IsParallel, Proc.TopologyLongName = sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName From f2027d03a350f24dddad76a02bcfc4cd35e7c5d8 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 12 Jul 2023 18:35:36 +0200 Subject: [PATCH 09/43] feature/MirroredMachinings: - implementato riconoscimento tasche sul fianco (e relativa specchiata) da fare in doppio; funzionanti, da testare - piccoli ritocchi a AffectedFaces e Topology --- LuaLibs/WFeatureTopology.lua | 10 +-- LuaLibs/WallExec.lua | 126 +++++++++++++++++++++++------------ LuaLibs/WallLib.lua | 14 ++-- 3 files changed, 95 insertions(+), 55 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index da012b4..afe47bb 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -34,7 +34,7 @@ end --------------------------------------------------------------------- -- restituisce gli id delle facce di Proc che hanno il numero di adiacenze nAdj -local function GetFacesWithGivenAdjacencyNumber( Proc, nAdj) +function WFeatureTopology.GetFacesWithGivenAdjacencyNumber( Proc, nAdj) local vAdj = GetAdjacencyMatrix( Proc) local vFacesWithGivenAdj = {} for i = 1, Proc.Fct do @@ -172,9 +172,9 @@ function WFeatureTopology.Classify( Proc) bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) local vTriangularFaces = GetTriangularFaces( Proc) local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) - local vFacesWithTwoAdj = GetFacesWithGivenAdjacencyNumber( Proc, 2) - local vFacesWithThreeAdj = GetFacesWithGivenAdjacencyNumber( Proc, 3) - local vFacesWithFourAdj = GetFacesWithGivenAdjacencyNumber( Proc, 4) + local vFacesWithTwoAdj = WFeatureTopology.GetFacesWithGivenAdjacencyNumber( Proc, 2) + local vFacesWithThreeAdj = WFeatureTopology.GetFacesWithGivenAdjacencyNumber( Proc, 3) + local vFacesWithFourAdj = WFeatureTopology.GetFacesWithGivenAdjacencyNumber( Proc, 4) if Proc.IsOutline then sFamily = 'OUTLINE' @@ -186,7 +186,7 @@ function WFeatureTopology.Classify( Proc) elseif Proc.Fct == 2 and bAllAnglesConcave and #vTriangularFaces == 1 then sFamily = 'Bevel' bIsThrough = false - elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyDimensionLongAsPart then + elseif Proc.Fct == 2 and bAllAnglesConcave then sFamily = 'Rabbet' bIsThrough = true elseif Proc.Fct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 427674e..cf6018a 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -640,52 +640,92 @@ function InsertScrapRemoval( nPhase) EgtSetCurrMachining( nActiveMachiningId) end -function VerifyLapJointMirrored( Proc, vProc, nPartId, b3Raw) - -- verifico se la geometria master è lavorabile in doppio (se la feature attuale è dal lato master) - local bIsThroughL = ( Proc.Fct == 2 and ( Proc.AffectedFaces == { true, true, false, false, true, true} or Proc.AffectedFaces == { true, false, false, true, true, true})) - local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) - local bAllowDifferentZ = false - -- 2 lati a L, passante - if bIsThroughL then - bAllowDifferentZ = true - -- 3 lati a U, passante - elseif bIsU then - -- sul fianco, parallela a X - if Proc.AffectedFaces == { false, true, false, false, true, true} or Proc.AffectedFaces == { false, false, false, true, true, true} then - bAllowDifferentZ = true - -- sopra - elseif Proc.AffectedFaces == { true, false, false, false, true, true} then - - -- sul fianco, parallela a Z - elseif Proc.AffectedFaces == { true, true, true, false, false, false} then - - end - - -- 3 lati a L, non passante - elseif Proc.Fct == 3 then - - -- 4 lati - elseif Proc.Fct == 4 then - - -- 5 lati, tasca standard - elseif Proc.Fct == 5 then - - end - -- se la condizione sopra è vera, verifico se esistono una o più altre features specchiate - - -- se le condizioni sopra sono vere, lo segno nelle proprietà delle feature -end - ------------------------------------------------------------------------------------------------------------- --- Cerca in vProc la presenza di feature da lavorare in doppio. -local function SetMirroredFeatures( vProc, nPartId, b3Raw) +-- Cerca in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri +local function SetMirroredFeatures( vProc, b3Raw) for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then - -- Proc.Double -> 2: specchiatura in Y - -- Proc.MirrorId -> Id della feature mirrorata - if ( ( LapJoint.Identify and Proc.Prc ~= 20) or DoubleCut.IdentifyStrict( Proc)) and true then -- aggiungere dipendenza da costante WallData!! - VerifyLapJointMirrored( Proc, vProc, nPartId, b3Raw) + -- AGGIUNGERE DIPENDENZA DA COSTANTE WALLDATA!! + + -- tasca sul fianco (non groove) + if Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2'or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or + Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' then + -- feature rivolta verso Y- e parallela a X + local bIsFeatureFacingFrontSide = Proc.AffectedFaces.Front + -- feature vicino al bordo Y- del grezzo + local bIsFeatureOnEdge = false + local nFaceLookingFrontSide + for j = 1, Proc.Fct do + if AreOppositeVectorApprox( Proc.Face[j].VtN, Y_AX()) then + nFaceLookingFrontSide = j - 1 + end + end + local dMaxDist = 300 + if nFaceLookingFrontSide then + local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) + local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) + bIsFeatureOnEdge = bIsFeatureFacingFrontSide and ( dSideDist < dMaxDist) + end + -- mirror XY sul lato opposto + local nMirrorId + local dYMirrorAx + local dDeltaZ + for j = 1, #vProc do + local ProcMirror = vProc[j] + if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then + -- feature specchiata rivolta verso Y+ e parallela a X + local bIsMirrorFeatureFacingBackSide = ProcMirror.AffectedFaces.Back + -- feature specchiata vicino al bordo Y+ del grezzo + local bIsMirrorFeatureOnEdge = false + local nMirrorFaceLookingBackSide + for k = 1, ProcMirror.Fct do + if AreSameVectorApprox( ProcMirror.Face[k].VtN, Y_AX()) then + nMirrorFaceLookingBackSide = k - 1 + end + end + if nMirrorFaceLookingBackSide then + local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingBackSide, GDB_ID.ROOT) + local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY()) + bIsMirrorFeatureOnEdge = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist) + end + -- box delle stesse dimensioni + local bIsMirrorFeatureSameDimension = false + local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + -- box allineati in X + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL + -- box che non si intersecano + local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) + -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni + if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdge and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping then + nMirrorId = ProcMirror.Id + local b3Tab = EgtGetTableArea() + local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 + dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + dDeltaZ = ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ() + end + end + end + -- se le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione + if nMirrorId and bIsFeatureFacingFrontSide and bIsFeatureOnEdge then + -- 2: specchiatura in Y + Proc.Double = 2 + Proc.MirrorId = nMirrorId + -- posizione Y dell'asse di specchiatura + Proc.MirrorAx = dYMirrorAx + -- Offset Z tra le feature + Proc.MirrorDeltaZ = dDeltaZ + end + + -- groove passante + elseif Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' then + end end end @@ -725,7 +765,7 @@ function WallExec.ProcessFeatures() WD.FindFeaturesInDouble( vProc, b3Raw) end - SetMirroredFeatures( vProc, nPartId, b3Raw) + SetMirroredFeatures( vProc, b3Raw) -- debug if EgtGetDebugLevel() >= 1 then diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index f6945db..2a1aa7a 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -405,20 +405,20 @@ end function WallLib.GetProcessAffectedFaces( Proc) local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') local b3Part = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) - local vtFacesAffected = { Bottom = false, Back = false, Top = false, Front = false, Left = false, Right = false} + local vtFacesAffected = { Top = false, Bottom = false, Front = false, Back = false, Left = false, Right = false} if Proc.Box and not Proc.Box:isEmpty() then - if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then - vtFacesAffected.Bottom = true - end - if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then - vtFacesAffected.Back = true - end if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 10 * GEO.EPS_SMALL then vtFacesAffected.Top = true end + if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then + vtFacesAffected.Bottom = true + end if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 10 * GEO.EPS_SMALL then vtFacesAffected.Front = true end + if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then + vtFacesAffected.Back = true + end if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 10 * GEO.EPS_SMALL then vtFacesAffected.Left = true end From 5b5ce504b1ae403b1e409a719a0f69a97ef2bb45 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 14 Jul 2023 19:02:13 +0200 Subject: [PATCH 10/43] =?UTF-8?q?-=20qualche=20piccola=20modifica=20a=20Wa?= =?UTF-8?q?llExec=20-=20in=20LapJoint=20(MakeTwoFaces=20e=20altri=20make,?= =?UTF-8?q?=20manca=20MakeMoreFaces)=20implementata=20parzialmente=20gesti?= =?UTF-8?q?one=20doppio=20-=20in=20MachiningLib=20aggiunta=20la=20possibil?= =?UTF-8?q?it=C3=A0=20di=20forzare=20una=20testa=20per=20milling=20e=20poc?= =?UTF-8?q?keting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/WMachiningLib.lua | 17 +++-- LuaLibs/WProcessLapJoint.lua | 133 +++++++++++++++++++++++++++++++++-- LuaLibs/WallExec.lua | 16 +++-- 3 files changed, 147 insertions(+), 19 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index d5a346c..b0c303a 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -3,7 +3,8 @@ -- 2023/03/09 Piccola correzione alla SideDepth in FindMilling -- In FindMilling aggiunta gestione spessore e massimo materiale nel caso di lam -- 2023/05/25 Aggiunta funzione AddMachining che incapsula EgtAddMachining trascrivendo le priorità btl dalle feature alle lavorazioni. --- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura dell'info ISOUTLINE alle lavorazioni. +-- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura di alcune info alle lavorazioni. +-- 2023/07/13 In FindMilling, FindPocketing aggiunta la possibilità di limitare la ricerca lavorazioni alla sola testa specificata. -- Tabella per definizione modulo local WMachiningLib = {} @@ -55,7 +56,7 @@ function WMachiningLib.FindCutting( sType, dDepth, nTool_ID) end --------------------------------------------------------------------- -function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID, dMaxDiam, dMaxMat, bTipFeed, dMinSideElev) +function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID, dMaxDiam, dMaxMat, bTipFeed, dMinSideElev, sHead) for i = 1, #Millings do local Milling = Millings[i] if Milling.On and Milling.Type == sType and SetCurrMachiningAndTool( Milling.Name) then @@ -69,6 +70,7 @@ function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID, dMaxDiam, d local dTTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') + local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if nMchType == MCH_MY.MILLING and ( not sTuuid or sTuuid == sMyTuuid) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and @@ -76,7 +78,8 @@ function WMachiningLib.FindMilling( sType, dDepth, sTuuid, nTool_ID, dMaxDiam, d ( not dMaxMat or dTMaxMat < dMaxMat + GEO.EPS_SMALL) and ( not bTipFeed or dTTipFeed > 1) and ( not dMinSideElev or dTMaxDepthOnSide > dMinSideElev - GEO.EPS_SMALL) and - ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then + ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) and + ( not sHead or sHead == sMyHead) then return Milling.Name, dTMaxDepth, dTMaxMat, dTDiam end end @@ -99,18 +102,20 @@ function WMachiningLib.FindNailing( nType) end --------------------------------------------------------------------- -function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID) +function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead) for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then local nMchType = EgtMdbGetCurrMachiningParam( MCH_MP.TYPE) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) - local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') + local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') + local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) if nMchType == MCH_MY.POCKETING and ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and - ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) then + ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) and + ( not sHead or sHead == sMyHead) then return Pocketing.Name, dTDiam, dTMaxDepth end end diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 39f1358..575aa19 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -731,6 +731,56 @@ local function MakeLocalSurf( ptP1, ptP2, ptP3, nAddGrpId) return nidFace end +--------------------------------------------------------------------- +local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) + local bIsToolDoubleOk = false + -- dimensioni utensile master + EgtTdbSetCurrTool( sToolMasterName) + local bIsBlade = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false + local dTMaxMat = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) + local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth()) + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0 + local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) + -- dimensioni utensile double + EgtTdbSetCurrTool( sToolDoubleName) + local bIsBladeDouble = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false + local dTMaxMatDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) + local dTMaxDepthDouble = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMatDouble, EgtTdbGetCurrToolMaxDepth()) + local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0 + local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) + -- controllo che siano uguali + bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and + ( abs( dTMaxMat - dTMaxMatDouble) < 100 * GEO.EPS_SMALL) and + ( abs( dTMaxDepth - dTMaxDepthDouble) < 100 * GEO.EPS_SMALL) and + ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and + ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and + ( bTipFeed == bTipFeedDouble) and + ( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and + EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + return bIsToolDoubleOk +end + +--------------------------------------------------------------------- +local function IsMachiningOkForDouble( sMachining) + local bDoubleOk = false + if sMachining and EgtMdbSetCurrMachining( sMachining) then + -- recupero l'utensile della lavorazione + local sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL) + if EgtTdbSetCurrTool( sToolMasterName or '') then + -- cerco eventuale utensile in doppio + local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') + if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then + bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName) + end + end + end + return bDoubleOk +end + --------------------------------------------------------------------- local function AddMillCornerMachining( nPartId, nNewProc, nFacInd, tFacAdj, nTypeConeCut, nAddGrpId, dToolDiam, dThick, sMilling, dOffsAng, dDepthMach, @@ -1282,6 +1332,14 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) local _, vtRef = EgtSurfTmFacetCenter( Proc.Id, nOthFac, GDB_ID.ROOT) -- recupero la lavorazione local sMilling = WM.FindMilling( 'Side') + if Proc.Double and Proc.Double == 2 then + local sMillingBackup = sMilling + sMilling = WM.FindMilling( 'Side', nil, nil, nil, nil, nil, nil, nil, 'H1') + if not IsMachiningOkForDouble( sMilling) then + Proc.Double = 0 + sMilling = sMillingBackup + end + end if not sMilling then return false end -- recupero i dati dell'utensile local dMillDiam = 20 @@ -1345,6 +1403,16 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) -- imposto modo di lavorare la faccia local nFaceUse = WL.GetNearestOrthoOpposite( vtRef, vtN) EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- leggo eventuali note esistenti della lavorazione + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- se lavorazione in doppio aggiungo le rispettive note + if Proc.Double and Proc.Double == 2 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) + sUserNotes = EgtSetValInNotes( sUserNotes, 'DeltaZ', Proc.MirrorDeltaZ) + end + -- scrivo le note della lavorazione + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -1355,7 +1423,7 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) end --------------------------------------------------------------------- -local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, dMaxDepthOnSide, bEnablePreMill, bMachFromDn, dAng, bAsEnablePreMill, nSinglePass, bExcludeFinishing) +local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, dMaxDepthOnSide, bEnablePreMill, bMachFromDn, dAng, bAsEnablePreMill, nSinglePass, bExcludeFinishing, bDoubleCustomMach) local sWarn -- dati della faccia principale (la più verticale) local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) @@ -1376,9 +1444,20 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d -- se ho lavorazione custom if sCustomMach then sMilling = sCustomMach + -- se avevo stabilito che la customMach non era adatta al double, setto per non specchiare + if not bDoubleCustomMach then Proc.Double = 0 end -- altrimenti la cerco else sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV)) + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + if Proc.Double and Proc.Double == 2 then + local sMillOnSideBackup = sMilling + sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, nil, 'H1') + if not IsMachiningOkForDouble( sMilling) then + Proc.Double = 0 + sMilling = sMillOnSideBackup + end + end end if not sMilling then local sErr = 'Error : SideGroove not found in library' @@ -1832,6 +1911,12 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) -- aggiungo alle note massima elevazione sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dMaxElev, 3)) + -- se lavorazione in doppio aggiungo le rispettive note + if Proc.Double and Proc.Double == 2 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) + sUserNotes = EgtSetValInNotes( sUserNotes, 'DeltaZ', Proc.MirrorDeltaZ) + end -- scrivo le note della lavorazione EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- setto il lato di lavoro standard @@ -2093,11 +2178,28 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) local sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev) if not sPocketing then sPocketing = WM.FindPocketing( 'Pocket', dDiam) + if Proc.Double and Proc.Double == 2 then + local sPocketingBackup = sPocketing + sPocketing = WM.FindPocketing( 'Pocket', dDiam, nil, nil, 'H1') + if not IsMachiningOkForDouble( sPocketing) then + Proc.Double = 0 + sPocketing = sPocketingBackup + end + end if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) return false, sErr end + else + if Proc.Double and Proc.Double == 2 then + local sPocketingBackup = sPocketing + sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev, nil, 'H1') + if not IsMachiningOkForDouble( sPocketing) then + Proc.Double = 0 + sPocketing = sPocketingBackup + end + end end -- recupero i dati dell'utensile local dMillDiam = 20 @@ -2147,6 +2249,12 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) -- imposto elevazione sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( min( dElev, dMaxDepth), 1)) + -- se lavorazione in doppio aggiungo le rispettive note + if Proc.Double and Proc.Double == 2 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) + sUserNotes = EgtSetValInNotes( sUserNotes, 'DeltaZ', Proc.MirrorDeltaZ) + end -- scrivo le note della lavorazione EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo @@ -2279,7 +2387,18 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) dMinSideElev = dDimY[2] end end - local sMillOnSide, dTMaxDepth, dMaxMat, dDiam = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev) + local sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev) + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + local bDoubleMillOnSide = false + if Proc.Double and Proc.Double == 2 then + local sMillOnSideBackup = sMillOnSide + sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev, 'H1') + if IsMachiningOkForDouble( sMillOnSide) then + bDoubleMillOnSide = true + else + sMillOnSide = sMillOnSideBackup + end + end local bEnableMillOnSide if sMillOnSide and nUseMillOnSide >= 1 then dMaxZVers = 0.866 @@ -2340,7 +2459,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) end -- se posso eseguire la lavorazione per distanza inferiore utensile o lavorazione preceduta da sgossatura gola if bInsertMach then - return MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng) + return MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, nil, nil, nil, bDoubleMillOnSide) else local sErr = 'Error feature not machinable (dimensions)' EgtOutLog( sErr) @@ -2408,10 +2527,10 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) local bMachFromDn = false local bInsertMach if dSideDist and dSideDist < dMaxDist then - -- se abilitata SideMill - if bEnableMillOnSide and dMaxDepthOnSide > 0 then + -- se abilitata SideMill oppure se la specchiata guarda in basso e quindi l'attacco deve essere a filo + if ( bEnableMillOnSide and dMaxDepthOnSide > 0) or ( Proc.Double == 2 and Proc.MirrorDeltaZ and abs( Proc.MirrorDeltaZ) > GEO.EPS_SMALL) then bLikeAsMakeFirstGroove = false - return MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove) + return MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) else local bOk, sErr = MakeByMill( Proc, nFacet, 1 - nFacet, nRawId, b3Raw, dSideDist) -- se angolo ottuso riprendo il lato quasi verticale @@ -2422,7 +2541,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) end elseif bEnableMillOnSide and dMaxDepthOnSide > 0 then bLikeAsMakeFirstGroove = true - local bOk, sErr = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove) + local bOk, sErr = MakeSideGrooveByMill( Proc, nFacetVert, nRawId, b3Raw, EgtIf( bEnableMillOnSide and dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, bMachFromDn, dAng, bLikeAsMakeFirstGroove, nil, nil, bDoubleMillOnSide) if bOk then return true end end -- se non inclinate o capacità di taglio non sufficiente o non molto grandi (80mm), provo con contornatura o svuotatura diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index cf6018a..72c266c 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -641,18 +641,18 @@ function InsertScrapRemoval( nPhase) end ------------------------------------------------------------------------------------------------------------- --- Cerca in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri +-- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri local function SetMirroredFeatures( vProc, b3Raw) for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then -- AGGIUNGERE DIPENDENZA DA COSTANTE WALLDATA!! - -- tasca sul fianco (non groove) if Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2'or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or - Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' then + Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' or + ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front) then -- feature rivolta verso Y- e parallela a X local bIsFeatureFacingFrontSide = Proc.AffectedFaces.Front -- feature vicino al bordo Y- del grezzo @@ -723,9 +723,6 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.MirrorDeltaZ = dDeltaZ end - -- groove passante - elseif Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' then - end end end @@ -792,6 +789,13 @@ function WallExec.ProcessFeatures() end end EgtOutLog( ' *** End AddMachinings ***', 1) + + ------- + -- LAVORAZIONI IN DOPPIO - QUI INSERIRE: + -- ELIMINAZIONE LAVORAZIONI MIRROR IN BASE A SETTAGGIO MACHININGTODELETE IN PROC + -- VERIFICA E UPDATE NOTE PER LAVORAZIONI IN CUI SI CONTROLLA SE I PERCORSI SONO SPECCHIATI + ------- + -- se macchina pareti if not WD.BEAM_MACHINE then -- riordino le lavorazioni tra tutti i pezzi From 5ff950015eaf19487db521382ab0280e948cd538 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 4 Aug 2023 18:57:04 +0200 Subject: [PATCH 11/43] - a WallExec aggiunta rimozione operazioni se legate a lavorazioni specchiate - modifiche varie per forzare sideGroove in caso la lavorazione principale sia una tasca cieca che guarda in alto - modificata MakeMoreFaces per contemplare lavorazioni in doppio --- LuaLibs/WProcessLapJoint.lua | 55 +++++++++++++++++++++++------------- LuaLibs/WallExec.lua | 42 +++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 21 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 1486626..e231d07 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -2212,30 +2212,23 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) end -- recupero la lavorazione + local bUseDElevToFindPocketing = true local sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev) if not sPocketing then + bUseDElevToFindPocketing = false sPocketing = WM.FindPocketing( 'Pocket', dDiam) - if Proc.Double and Proc.Double == 2 then - local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dDiam, nil, nil, 'H1') - if not IsMachiningOkForDouble( sPocketing) then - Proc.Double = 0 - sPocketing = sPocketingBackup - end - end if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) return false, sErr end - else - if Proc.Double and Proc.Double == 2 then - local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev, nil, 'H1') - if not IsMachiningOkForDouble( sPocketing) then - Proc.Double = 0 - sPocketing = sPocketingBackup - end + end + if Proc.Double and Proc.Double == 2 then + local sPocketingBackup = sPocketing + sPocketing = WM.FindPocketing( 'Pocket', dDiam, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') + if not IsMachiningOkForDouble( sPocketing) then + Proc.Double = 0 + sPocketing = sPocketingBackup end end -- recupero i dati dell'utensile @@ -2681,6 +2674,17 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) local dSideElev = WL.GetFaceElevation( Proc.Id, nFacInd) -- se abilitata lavorazione ribasso con fresa di fianco e parametro Q03 abilitato local sMillOnSide, dTMaxDepth, dMaxMat, dDiam = WM.FindMilling( 'SideMill', nil, nil, nil, nil, min( dH, dV), nil, dSideElev) + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + local bDoubleMillOnSide = false + if Proc.Double and Proc.Double == 2 then + local sMillOnSideBackup = sMillOnSide + sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, min( dH, dV), nil, dSideElev, 'H1') + if IsMachiningOkForDouble( sMillOnSide) then + bDoubleMillOnSide = true + else + sMillOnSide = sMillOnSideBackup + end + end local _, nUseMillOnSide = EvaluateQParam( Proc) -- se ho abilitata lavorazione di fresa di fianco if Proc.Fct >= 3 and sMillOnSide and nUseMillOnSide >= 1 and not bIsSmallSlot then @@ -2721,14 +2725,27 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) nSinglePass = 2 bMakeFirstGroove = false end - return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, EgtIf( dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, nil, nil, bLikeAsMakeFirstGroove, nSinglePass) + return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, EgtIf( dMaxDepthOnSide, sMillOnSide, nil), dMaxDepthOnSide, bMakeFirstGroove, nil, nil, bLikeAsMakeFirstGroove, nSinglePass, nil, bDoubleMillOnSide) end else -- fresatura (se definita); se disponibile, cerco di usare un utensile che non lavori al limite della capacità di sottosquadro - local sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, 1.2 * dSideElev) + local dSideElevMultiplier = 1.2 + local sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElevMultiplier * dSideElev) -- se non ho trovato un utensile un po' più grande del sottosquadro richiesto, passo alla ricerca standard if not sMilling then sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElev) + dSideElevMultiplier = 1 + end + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + bDoubleMillOnSide = false + if Proc.Double and Proc.Double == 2 then + local sMillOnSideBackup = sMillOnSide + sMillOnSide = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElevMultiplier * dSideElev, 'H1') + if IsMachiningOkForDouble( sMillOnSide) then + bDoubleMillOnSide = true + else + sMillOnSide = sMillOnSideBackup + end end -- recupero i dati dell'utensile local dMaxMat = 1000 @@ -2753,7 +2770,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) end end if sMilling and dElev < dMaxDepthOnSide then - return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, sMilling) + return MakeSideGrooveByMill( Proc, nFacInd, nRawId, b3Raw, sMilling, nil, nil, nil, nil, nil, nil, nil, bDoubleMillOnSide) -- altrimenti sega a catena else return MakeByChainSaw( Proc, nFacInd, nRawId, b3Raw, dElev, dH, dV) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 20713a8..f3ca414 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -673,6 +673,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local nMirrorId local dYMirrorAx local dDeltaZ + local bIsMirrorTowardsBottom = false for j = 1, #vProc do local ProcMirror = vProc[j] if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then @@ -709,6 +710,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() dDeltaZ = ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ() + bIsMirrorTowardsBottom = ProcMirror.AffectedFaces.Bottom end end end @@ -721,6 +723,11 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.MirrorAx = dYMirrorAx -- Offset Z tra le feature Proc.MirrorDeltaZ = dDeltaZ + -- se sono groove cieche e la principale guarda su e l'altra guarda giù, la principale va trattata come sidegroove in accordo con la seconda + if ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4') and + Proc.AffectedFaces.Top and bIsMirrorTowardsBottom then + Proc.Stype = 2 + end end end @@ -783,7 +790,7 @@ function WallExec.ProcessFeatures() else table.insert( Stats, {Err=0, Msg='', Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end - elseif not Proc.Double then + elseif not Proc.Double then local sMsg = 'Feature not machinable by orientation' table.insert( Stats, {Err=1, Msg=sMsg, Rot=0, CutId=Proc.CutId, TaskId=Proc.TaskId}) end @@ -795,7 +802,38 @@ function WallExec.ProcessFeatures() -- ELIMINAZIONE LAVORAZIONI MIRROR IN BASE A SETTAGGIO MACHININGTODELETE IN PROC -- VERIFICA E UPDATE NOTE PER LAVORAZIONI IN CUI SI CONTROLLA SE I PERCORSI SONO SPECCHIATI ------- - + -- setto quali sono le lavorazioni da disattivare perchè specchiate di lavorazioni in doppio + local vProcToDisable = {} + for i = 1, #vProc do + local Proc = vProc[i] + if Proc.Double and Proc.Double > 0 then + for j = 1, #vProc do + local ProcMirror = vProc[j] + if Proc.MirrorId == ProcMirror.Id then + table.insert( vProcToDisable, ProcMirror.Id) + end + end + end + end + -- cancello le operazioni legate a lavorazioni specchiate + local nOperId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + while nOperId do + EgtSetCurrMachining( nOperId) + local nOperationProcIds = EgtGetMachiningGeometry() + local nOperationProcId = EgtIf( #nOperationProcIds[1] > 1, nOperationProcIds[1][1], nOperationProcIds[1]) + local nCurrentOperId = nOperId + for i = 1, #vProcToDisable do + local ProcId = vProcToDisable[i] + if nOperationProcId == ProcId then + nOperId = EgtGetNextOperation( nOperId) + EgtRemoveOperation(nCurrentOperId) + break + end + end + if nCurrentOperId == nOperId then + nOperId = EgtGetNextOperation( nOperId) + end + end -- se macchina pareti if not WD.BEAM_MACHINE then -- riordino le lavorazioni tra tutti i pezzi From e6bd4e7e94c7332f89f97000723dd16df108c453 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 7 Aug 2023 10:53:35 +0200 Subject: [PATCH 12/43] piccola correzione a WallExec --- LuaLibs/WallExec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index f3ca414..47b90be 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -820,7 +820,7 @@ function WallExec.ProcessFeatures() while nOperId do EgtSetCurrMachining( nOperId) local nOperationProcIds = EgtGetMachiningGeometry() - local nOperationProcId = EgtIf( #nOperationProcIds[1] > 1, nOperationProcIds[1][1], nOperationProcIds[1]) + local nOperationProcId = nOperationProcIds[1] local nCurrentOperId = nOperId for i = 1, #vProcToDisable do local ProcId = vProcToDisable[i] From 5e6dfe320f8b7e8ade84d175e8131bdde6d293d9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 9 Aug 2023 17:16:47 +0200 Subject: [PATCH 13/43] - aggiunta gestione in doppio di forature e groove passanti (rivolte verso Z+) - lieve correzione a check utensile doppio - aggiunto interasse minimo per lavorazioni in doppio --- LuaLibs/WProcessDrill.lua | 63 ++++++++++++-- LuaLibs/WProcessLapJoint.lua | 4 +- LuaLibs/WallExec.lua | 159 +++++++++++++++++++++++++++++++++-- 3 files changed, 209 insertions(+), 17 deletions(-) diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 6865dc9..690f664 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -55,7 +55,7 @@ end --------------------------------------------------------------------- -- Classificazione della feature -function WPD.Classify( Proc, b3Raw) +function WPD.Classify( Proc, b3Raw) -- recupero e verifico l'entità foro local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 @@ -156,6 +156,41 @@ function WPD.RotateClassify( Proc) end end +--------------------------------------------------------------------- +local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) + local bIsToolDoubleOk = false + -- dimensioni utensile master + EgtTdbSetCurrTool( sToolMasterName) + local dTMaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + -- dimensioni utensile double + EgtTdbSetCurrTool( sToolDoubleName) + local dTMaxMatDouble = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + -- controllo che siano uguali + bIsToolDoubleOk = ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and + ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and + EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + return bIsToolDoubleOk +end + +--------------------------------------------------------------------- +local function IsMachiningOkForDouble( sMachining) + local bDoubleOk = false + if sMachining and EgtMdbSetCurrMachining( sMachining) then + -- recupero l'utensile della lavorazione + local sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL) + if EgtTdbSetCurrTool( sToolMasterName or '') then + -- cerco eventuale utensile in doppio + local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') + if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then + bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName) + end + end + end + return bDoubleOk +end + --------------------------------------------------------------------- local function IsHorizLongDrill( Proc) -- recupero e verifico l'entità foro @@ -263,10 +298,21 @@ function WPD.Make( Proc, nRawId, b3Raw) end end end + local bUseDLenToFindDrilling = true local sDrilling, nType = WM.FindDrilling( dDiam, dLen, sHead) if not sDrilling then + bUseDLenToFindDrilling = false sDrilling, nType = WM.FindDrilling( dDiam, nil, sHead) end + -- se Proc è settata per essere specchiata cerco la lavorazione adatta e verifico possa essere effettivamente specchiata + if Proc.Double and Proc.Double == 2 then + local sDrillingBackup = sDrilling + sDrilling = WM.FindDrilling( dDiam, EgtIf( bUseDLenToFindDrilling, dLen, nil), 'H1') + if not IsMachiningOkForDouble( sDrilling) then + Proc.Double = 0 + sDrilling = sDrillingBackup + end + end if sHead and not sDrilling then sDrilling, nType = WM.FindDrilling( dDiam, dLen) if not sDrilling then @@ -447,21 +493,26 @@ function WPD.Make( Proc, nRawId, b3Raw) end end EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) - -- Note utente - local sUserNotes = '' + -- leggo eventuali note esistenti della lavorazione + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) -- se foratura o svuotatura, dichiarazione nessuna generazione sfridi per Vmill if nType == 'Drill' or nType == 'Pocket' then - sUserNotes = 'VMRS=0;' + sUserNotes = EgtSetValInNotes( sUserNotes, 'VMRS', 0) end -- se foratura if nType == 'Drill' then -- aggiungo alle note massima elevazione (coincide con affondamento) - sUserNotes = sUserNotes .. 'MaxElev=' .. EgtNumToString( dDepth, 1) .. ';' + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', EgtNumToString( dDepth, 1)) -- se foro passante, aggiungo questa qualifica alle note if bOpen then - sUserNotes = sUserNotes .. 'Open=1;' + sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 1) end end + -- se lavorazione in doppio aggiungo le rispettive note + if Proc.Double and Proc.Double == 2 then + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) + end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo if not EgtApplyMachining( true, false) then diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 90e69ce..b04d9ce 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -758,8 +758,8 @@ local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) -- controllo che siano uguali bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and - ( abs( dTMaxMat - dTMaxMatDouble) < 100 * GEO.EPS_SMALL) and - ( abs( dTMaxDepth - dTMaxDepthDouble) < 100 * GEO.EPS_SMALL) and + ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and + ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and ( bTipFeed == bTipFeedDouble) and diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 47b90be..e0e56e9 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -192,7 +192,7 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc.TaskId = nTaskId Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) Proc.IsOutline = ( Proc.Prc == 251 or Proc.Prc == 252) - + -- recupero l'elenco delle facce della parte interessate dalla feature Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) @@ -201,7 +201,7 @@ function WallExec.CollectFeatures( PartId, b3Raw) for i = 1, Proc.Fct do Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ), Elevation = WL.GetFaceElevation( Proc.Id, i - 1, PartId)} end - + if Proc.Box and not Proc.Box:isEmpty() then table.insert( vProc, Proc) -- se foro @@ -643,16 +643,19 @@ end ------------------------------------------------------------------------------------------------------------- -- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri local function SetMirroredFeatures( vProc, b3Raw) + local dMinimumDistanceMirroredFeatures = 780 + local vGroovesThrough = {} + local vDrillings = {} for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then -- AGGIUNGERE DIPENDENZA DA COSTANTE WALLDATA!! - + -- tutte le rabbet, tunnel e groove, tranne le groove passanti che guardano Z+, vengono confrontati con possibili feature mirror if Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2'or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' or - ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front) then + ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) then -- feature rivolta verso Y- e parallela a X local bIsFeatureFacingFrontSide = Proc.AffectedFaces.Front -- feature vicino al bordo Y- del grezzo @@ -663,7 +666,7 @@ local function SetMirroredFeatures( vProc, b3Raw) nFaceLookingFrontSide = j - 1 end end - local dMaxDist = 300 + local dMaxDist = 100 if nFaceLookingFrontSide then local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) @@ -678,7 +681,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local ProcMirror = vProc[j] if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then -- feature specchiata rivolta verso Y+ e parallela a X - local bIsMirrorFeatureFacingBackSide = ProcMirror.AffectedFaces.Back + local bIsMirrorFeatureFacingBackSide = EgtIf( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3', ProcMirror.AffectedFaces.Back and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right, ProcMirror.AffectedFaces.Back) -- feature specchiata vicino al bordo Y+ del grezzo local bIsMirrorFeatureOnEdge = false local nMirrorFaceLookingBackSide @@ -703,8 +706,11 @@ local function SetMirroredFeatures( vProc, b3Raw) local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL -- box che non si intersecano local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) + -- distanza minima tra le feature + local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) + local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni - if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdge and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping then + if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdge and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then nMirrorId = ProcMirror.Id local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 @@ -729,10 +735,145 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.Stype = 2 end end - + -- le groove passanti, parallele a X e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio + elseif Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right then + table.insert( vGroovesThrough, Proc) + -- i fori verticali e aperti verso Z+ vanno raccolti, ordinati e accoppiati a 2 a 2 per il doppio a parità di X + elseif Proc.TopologyLongName == 'DRILLING' then + -- recupero e verifico l'entità foro + local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 + if AuxId then AuxId = AuxId + Proc.Id end + if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then + return false + end + -- recupero il vettore del foro + local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) + if Proc.AffectedFaces.Top and AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then + table.insert( vDrillings, Proc) + end end end end + + -- ordino le groove passanti rivolte verso Z+ in base alla Y crescente + table.sort( vGroovesThrough, function( a, b) return b.Box:getCenter():getY() > a.Box:getCenter():getY() end) + + -- funzione per l'ordinamento dei fori + local function SortDrillingsForMirror( Proc1, Proc2) + local Proc1X = Proc1.Box:getCenter():getX() + local Proc1Y = Proc1.Box:getCenter():getY() + local Proc2X = Proc2.Box:getCenter():getX() + local Proc2Y = Proc2.Box:getCenter():getY() + if Proc1X < Proc2X - 10 * GEO.EPS_SMALL then + return true + elseif abs( Proc1X - Proc2X) < 10 * GEO.EPS_SMALL then + if Proc1Y < Proc2Y - 10 * GEO.EPS_SMALL then + return true + end + end + end + -- ordino le forature aperte verso Z+ in base alla X e poi alla Y crescente + table.sort( vDrillings, SortDrillingsForMirror) + + -- accoppio le groove passanti rivolte verso Z+ + local nCurrentGroove = 1 + while nCurrentGroove <= #vGroovesThrough do + local Proc = vGroovesThrough[nCurrentGroove] + if Proc.Flg ~= 0 then + local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + local j = nCurrentGroove + 1 + while j <= #vGroovesThrough do + local ProcMirror = vGroovesThrough[j] + local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) + -- feature non disattivata e diversa dala i-esima + local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) + -- box delle stesse dimensioni + local bIsMirrorFeatureSameDimension = false + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + -- box allineati in X + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL + -- box che non si intersecano + local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) + -- distanza minima tra le feature + local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) + local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL + -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni + if bIsMirrorIdOk and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then + local dYMirrorAx + local b3Tab = EgtGetTableArea() + local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 + dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + -- scrivo i parametri nella lavorazione + -- 2: specchiatura in Y + Proc.Double = 2 + Proc.MirrorId = ProcMirror.Id + -- posizione Y dell'asse di specchiatura + Proc.MirrorAx = dYMirrorAx + -- rimuovo dalla lista le groove già assegnate + local ProcMirrorOldId = ProcMirror.Id + table.remove( vGroovesThrough, nCurrentGroove) + if j > #vGroovesThrough or ( vGroovesThrough[j].Id ~= ProcMirrorOldId) then j = j - 1 end + table.remove( vGroovesThrough, j) + nCurrentGroove = 0 + break + end + j = j + 1 + end + end + nCurrentGroove = nCurrentGroove + 1 + end + + -- accoppio le forature + local nCurrentDrilling = 1 + while nCurrentDrilling <= #vDrillings do + local Proc = vDrillings[nCurrentDrilling] + if Proc.Flg ~= 0 then + local j = nCurrentDrilling + 1 + local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + while j <= #vDrillings do + local ProcMirror = vDrillings[j] + local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) + -- feature non disattivata e diversa dala i-esima + local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) + -- box delle stesse dimensioni + local bIsMirrorFeatureSameDimension = false + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + -- box allineati in X + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 10 * GEO.EPS_SMALL + -- box che non si intersecano + local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) + -- distanza minima tra le feature + local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) + local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL + -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni + if bIsMirrorIdOk and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then + local dYMirrorAx + local b3Tab = EgtGetTableArea() + local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 + dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + -- scrivo i parametri nella lavorazione + -- 2: specchiatura in Y + Proc.Double = 2 + Proc.MirrorId = ProcMirror.Id + -- posizione Y dell'asse di specchiatura + Proc.MirrorAx = dYMirrorAx + -- rimuovo dalla lista le groove già assegnate + local ProcMirrorOldId = ProcMirror.Id + table.remove( vDrillings, nCurrentDrilling) + if j > #vDrillings or ( vDrillings[j].Id ~= ProcMirrorOldId) then j = j - 1 end + table.remove( vDrillings, j) + nCurrentDrilling = 0 + break + end + j = j + 1 + end + end + nCurrentDrilling = nCurrentDrilling + 1 + end end ------------------------------------------------------------------------------------------------------------- @@ -820,7 +961,7 @@ function WallExec.ProcessFeatures() while nOperId do EgtSetCurrMachining( nOperId) local nOperationProcIds = EgtGetMachiningGeometry() - local nOperationProcId = nOperationProcIds[1] + local nOperationProcId = nOperationProcIds[1][1] local nCurrentOperId = nOperId for i = 1, #vProcToDisable do local ProcId = vProcToDisable[i] From 3326f8ef4efe43eda404cbbf1caeb3109e3445c9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 9 Aug 2023 18:25:32 +0200 Subject: [PATCH 14/43] - corretto id geometria per disattivazione fori - massima distanza dal bordo pannello portata a 200 mm - migliorie stilistiche --- LuaLibs/WallExec.lua | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index e0e56e9..65d3aaf 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -666,7 +666,7 @@ local function SetMirroredFeatures( vProc, b3Raw) nFaceLookingFrontSide = j - 1 end end - local dMaxDist = 100 + local dMaxDist = 200 if nFaceLookingFrontSide then local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) @@ -781,9 +781,9 @@ local function SetMirroredFeatures( vProc, b3Raw) local Proc = vGroovesThrough[nCurrentGroove] if Proc.Flg ~= 0 then local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local j = nCurrentGroove + 1 - while j <= #vGroovesThrough do - local ProcMirror = vGroovesThrough[j] + local nCurrentMirrorGroove = nCurrentGroove + 1 + while nCurrentMirrorGroove <= #vGroovesThrough do + local ProcMirror = vGroovesThrough[nCurrentMirrorGroove] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) -- feature non disattivata e diversa dala i-esima local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) @@ -814,12 +814,12 @@ local function SetMirroredFeatures( vProc, b3Raw) -- rimuovo dalla lista le groove già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vGroovesThrough, nCurrentGroove) - if j > #vGroovesThrough or ( vGroovesThrough[j].Id ~= ProcMirrorOldId) then j = j - 1 end - table.remove( vGroovesThrough, j) + if nCurrentMirrorGroove > #vGroovesThrough or ( vGroovesThrough[nCurrentMirrorGroove].Id ~= ProcMirrorOldId) then nCurrentMirrorGroove = nCurrentMirrorGroove - 1 end + table.remove( vGroovesThrough, nCurrentMirrorGroove) nCurrentGroove = 0 break end - j = j + 1 + nCurrentMirrorGroove = nCurrentMirrorGroove + 1 end end nCurrentGroove = nCurrentGroove + 1 @@ -830,10 +830,10 @@ local function SetMirroredFeatures( vProc, b3Raw) while nCurrentDrilling <= #vDrillings do local Proc = vDrillings[nCurrentDrilling] if Proc.Flg ~= 0 then - local j = nCurrentDrilling + 1 + local nCurrentMirrorDrilling = nCurrentDrilling + 1 local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - while j <= #vDrillings do - local ProcMirror = vDrillings[j] + while nCurrentMirrorDrilling <= #vDrillings do + local ProcMirror = vDrillings[nCurrentMirrorDrilling] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) -- feature non disattivata e diversa dala i-esima local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) @@ -864,12 +864,12 @@ local function SetMirroredFeatures( vProc, b3Raw) -- rimuovo dalla lista le groove già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vDrillings, nCurrentDrilling) - if j > #vDrillings or ( vDrillings[j].Id ~= ProcMirrorOldId) then j = j - 1 end - table.remove( vDrillings, j) + if nCurrentMirrorDrilling > #vDrillings or ( vDrillings[nCurrentMirrorDrilling].Id ~= ProcMirrorOldId) then nCurrentMirrorDrilling = nCurrentMirrorDrilling - 1 end + table.remove( vDrillings, nCurrentMirrorDrilling) nCurrentDrilling = 0 break end - j = j + 1 + nCurrentMirrorDrilling = nCurrentMirrorDrilling + 1 end end nCurrentDrilling = nCurrentDrilling + 1 @@ -951,7 +951,15 @@ function WallExec.ProcessFeatures() for j = 1, #vProc do local ProcMirror = vProc[j] if Proc.MirrorId == ProcMirror.Id then - table.insert( vProcToDisable, ProcMirror.Id) + -- per i fori l'operazione si basa sulla geometria ausiliaria + if Proc.TopologyLongName == 'DRILLING' then + local AuxId = EgtGetInfo( ProcMirror.Id, 'AUXID', 'i') or 0 + if AuxId then AuxId = AuxId + ProcMirror.Id end + table.insert( vProcToDisable, AuxId) + -- per tutte le altre lavorazioni si usa la geometria della feature + else + table.insert( vProcToDisable, ProcMirror.Id) + end end end end From d0cecd6a0d57970549693ce3aebfc9ff314d1105 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 10 Aug 2023 16:54:02 +0200 Subject: [PATCH 15/43] - in WallLib -> affectedFaces modificata tolleranza - in WallExec introduzione costanti distinte per tolleranze ricerca tasche e fori in doppio - altre piccole migliorie --- LuaLibs/WallExec.lua | 122 ++++++++++++++++++++++++------------------- LuaLibs/WallLib.lua | 12 ++--- 2 files changed, 74 insertions(+), 60 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 65d3aaf..316ba33 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -640,26 +640,47 @@ function InsertScrapRemoval( nPhase) EgtSetCurrMachining( nActiveMachiningId or GDB_ID.NULL) end +------------------------------------------------------------------------------------------------------------- +-- funzione per l'ordinamento delle features in doppio da accoppiare +-- ordinate prima in base alla X e poi alla Y +local function SortFeaturesForMirror( Proc1, Proc2) + local TOL = EgtIf( Proc1.TopologyLongName == 'DRILLING', WD.DOUBLE_HEAD_DRILLING_TOLERANCE , WD.DOUBLE_HEAD_POCKET_TOLERANCE) + local Proc1X = Proc1.Box:getCenter():getX() + local Proc1Y = Proc1.Box:getCenter():getY() + local Proc2X = Proc2.Box:getCenter():getX() + local Proc2Y = Proc2.Box:getCenter():getY() + if Proc1X < Proc2X - TOL then + return true + elseif abs( Proc1X - Proc2X) < TOL then + if Proc1Y < Proc2Y - TOL then + return true + end + end +end + ------------------------------------------------------------------------------------------------------------- -- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri local function SetMirroredFeatures( vProc, b3Raw) + local dMinimumDistanceMirroredFeatures = 780 local vGroovesThrough = {} local vDrillings = {} + + -- in base alla topologia cerco subito la feature mirror oppure raccolgo tutte le feature simili e le accoppio successivamente for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then - -- AGGIUNGERE DIPENDENZA DA COSTANTE WALLDATA!! - -- tutte le rabbet, tunnel e groove, tranne le groove passanti che guardano Z+, vengono confrontati con possibili feature mirror - if Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2'or - Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or - Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or - Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' or - ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) then - -- feature rivolta verso Y- e parallela a X - local bIsFeatureFacingFrontSide = Proc.AffectedFaces.Front + -- tutte le rabbet, tunnel e groove sul fianco vengono confrontate con possibili feature mirror + if WD.DOUBLE_HEAD_POCKET and + ( + ( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and Proc.AffectedFaces.Front) or + ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' and Proc.AffectedFaces.Front) or + ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Front) or + ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Front) or + ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) + ) then -- feature vicino al bordo Y- del grezzo - local bIsFeatureOnEdge = false + local bIsFeatureOnEdgeOrPocket = false local nFaceLookingFrontSide for j = 1, Proc.Fct do if AreOppositeVectorApprox( Proc.Face[j].VtN, Y_AX()) then @@ -670,20 +691,21 @@ local function SetMirroredFeatures( vProc, b3Raw) if nFaceLookingFrontSide then local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) - bIsFeatureOnEdge = bIsFeatureFacingFrontSide and ( dSideDist < dMaxDist) + bIsFeatureOnEdgeOrPocket = dSideDist < dMaxDist end -- mirror XY sul lato opposto local nMirrorId local dYMirrorAx local dDeltaZ local bIsMirrorTowardsBottom = false + -- cerco una possibile feature mirror for j = 1, #vProc do local ProcMirror = vProc[j] if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then -- feature specchiata rivolta verso Y+ e parallela a X local bIsMirrorFeatureFacingBackSide = EgtIf( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3', ProcMirror.AffectedFaces.Back and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right, ProcMirror.AffectedFaces.Back) -- feature specchiata vicino al bordo Y+ del grezzo - local bIsMirrorFeatureOnEdge = false + local bIsMirrorFeatureOnEdgeOrPocket = false local nMirrorFaceLookingBackSide for k = 1, ProcMirror.Fct do if AreSameVectorApprox( ProcMirror.Face[k].VtN, Y_AX()) then @@ -693,24 +715,24 @@ local function SetMirroredFeatures( vProc, b3Raw) if nMirrorFaceLookingBackSide then local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingBackSide, GDB_ID.ROOT) local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY()) - bIsMirrorFeatureOnEdge = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist) + bIsMirrorFeatureOnEdgeOrPocket = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist) end -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = false local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box allineati in X - local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5 -- box che non si intersecano local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) -- distanza minima tra le feature local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni - if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdge and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then + if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdgeOrPocket and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then nMirrorId = ProcMirror.Id local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 @@ -720,8 +742,8 @@ local function SetMirroredFeatures( vProc, b3Raw) end end end - -- se le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione - if nMirrorId and bIsFeatureFacingFrontSide and bIsFeatureOnEdge then + -- se ho trovato una feature mirror e le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione + if nMirrorId and bIsFeatureOnEdgeOrPocket then -- 2: specchiatura in Y Proc.Double = 2 Proc.MirrorId = nMirrorId @@ -735,18 +757,22 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.Stype = 2 end end - -- le groove passanti, parallele a X e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio - elseif Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right then + -- le groove non sul fianco e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio + elseif WD.DOUBLE_HEAD_POCKET and + ( + ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) or + ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right)) or + ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top) + ) then table.insert( vGroovesThrough, Proc) -- i fori verticali e aperti verso Z+ vanno raccolti, ordinati e accoppiati a 2 a 2 per il doppio a parità di X - elseif Proc.TopologyLongName == 'DRILLING' then - -- recupero e verifico l'entità foro + elseif WD.DOUBLE_HEAD_DRILLING and Proc.TopologyLongName == 'DRILLING' then + -- recupero e verifico la geometria del foro local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + Proc.Id end if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then return false end - -- recupero il vettore del foro local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB) if Proc.AffectedFaces.Top and AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then table.insert( vDrillings, Proc) @@ -755,25 +781,11 @@ local function SetMirroredFeatures( vProc, b3Raw) end end - -- ordino le groove passanti rivolte verso Z+ in base alla Y crescente - table.sort( vGroovesThrough, function( a, b) return b.Box:getCenter():getY() > a.Box:getCenter():getY() end) - - -- funzione per l'ordinamento dei fori - local function SortDrillingsForMirror( Proc1, Proc2) - local Proc1X = Proc1.Box:getCenter():getX() - local Proc1Y = Proc1.Box:getCenter():getY() - local Proc2X = Proc2.Box:getCenter():getX() - local Proc2Y = Proc2.Box:getCenter():getY() - if Proc1X < Proc2X - 10 * GEO.EPS_SMALL then - return true - elseif abs( Proc1X - Proc2X) < 10 * GEO.EPS_SMALL then - if Proc1Y < Proc2Y - 10 * GEO.EPS_SMALL then - return true - end - end - end - -- ordino le forature aperte verso Z+ in base alla X e poi alla Y crescente - table.sort( vDrillings, SortDrillingsForMirror) + -- ordinamento delle feature che vanno accoppiate + -- groove verso Z+ + table.sort( vGroovesThrough, SortFeaturesForMirror) + -- forature verso Z+ + table.sort( vDrillings, SortFeaturesForMirror) -- accoppio le groove passanti rivolte verso Z+ local nCurrentGroove = 1 @@ -785,15 +797,15 @@ local function SetMirroredFeatures( vProc, b3Raw) while nCurrentMirrorGroove <= #vGroovesThrough do local ProcMirror = vGroovesThrough[nCurrentMirrorGroove] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - -- feature non disattivata e diversa dala i-esima + -- feature non disattivata e diversa da nCurrentGroove local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = false - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box allineati in X - local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box che non si intersecano local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) -- distanza minima tra le feature @@ -814,6 +826,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- rimuovo dalla lista le groove già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vGroovesThrough, nCurrentGroove) + -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorGroove if nCurrentMirrorGroove > #vGroovesThrough or ( vGroovesThrough[nCurrentMirrorGroove].Id ~= ProcMirrorOldId) then nCurrentMirrorGroove = nCurrentMirrorGroove - 1 end table.remove( vGroovesThrough, nCurrentMirrorGroove) nCurrentGroove = 0 @@ -835,15 +848,15 @@ local function SetMirroredFeatures( vProc, b3Raw) while nCurrentMirrorDrilling <= #vDrillings do local ProcMirror = vDrillings[nCurrentMirrorDrilling] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - -- feature non disattivata e diversa dala i-esima + -- feature non disattivata e diversa da nCurrentDrilling local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = false - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and - abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL + bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and + abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and + abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) -- box allineati in X - local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 10 * GEO.EPS_SMALL + local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) -- box che non si intersecano local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) -- distanza minima tra le feature @@ -864,6 +877,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- rimuovo dalla lista le groove già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vDrillings, nCurrentDrilling) + -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorDrilling if nCurrentMirrorDrilling > #vDrillings or ( vDrillings[nCurrentMirrorDrilling].Id ~= ProcMirrorOldId) then nCurrentMirrorDrilling = nCurrentMirrorDrilling - 1 end table.remove( vDrillings, nCurrentMirrorDrilling) nCurrentDrilling = 0 diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index 2a1aa7a..f163bbb 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -407,22 +407,22 @@ function WallLib.GetProcessAffectedFaces( Proc) local b3Part = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) local vtFacesAffected = { Top = false, Bottom = false, Front = false, Back = false, Left = false, Right = false} if Proc.Box and not Proc.Box:isEmpty() then - if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 10 * GEO.EPS_SMALL then + if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 500 * GEO.EPS_SMALL then vtFacesAffected.Top = true end - if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 10 * GEO.EPS_SMALL then + if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 500 * GEO.EPS_SMALL then vtFacesAffected.Bottom = true end - if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 10 * GEO.EPS_SMALL then + if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 500 * GEO.EPS_SMALL then vtFacesAffected.Front = true end - if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 10 * GEO.EPS_SMALL then + if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 500 * GEO.EPS_SMALL then vtFacesAffected.Back = true end - if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 10 * GEO.EPS_SMALL then + if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 500 * GEO.EPS_SMALL then vtFacesAffected.Left = true end - if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 10 * GEO.EPS_SMALL then + if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 500 * GEO.EPS_SMALL then vtFacesAffected.Right = true end end From 4a5c213de61d0e48416ba90a39a7bb2264285a16 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 11 Aug 2023 18:51:02 +0200 Subject: [PATCH 16/43] - refactoring di SetMirroredMachinings - da definire cosa specchiare se feature non sul bordo --- LuaLibs/WallExec.lua | 220 +++++++++++++++++++++---------------------- 1 file changed, 105 insertions(+), 115 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 316ba33..5a00a45 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -644,7 +644,7 @@ end -- funzione per l'ordinamento delle features in doppio da accoppiare -- ordinate prima in base alla X e poi alla Y local function SortFeaturesForMirror( Proc1, Proc2) - local TOL = EgtIf( Proc1.TopologyLongName == 'DRILLING', WD.DOUBLE_HEAD_DRILLING_TOLERANCE , WD.DOUBLE_HEAD_POCKET_TOLERANCE) + local TOL = EgtIf( Proc1.TopologyLongName == 'DRILLING', WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1 , WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) local Proc1X = Proc1.Box:getCenter():getX() local Proc1Y = Proc1.Box:getCenter():getY() local Proc2X = Proc2.Box:getCenter():getX() @@ -663,109 +663,23 @@ end local function SetMirroredFeatures( vProc, b3Raw) local dMinimumDistanceMirroredFeatures = 780 - local vGroovesThrough = {} + local vPockets = {} local vDrillings = {} - -- in base alla topologia cerco subito la feature mirror oppure raccolgo tutte le feature simili e le accoppio successivamente for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then - -- tutte le rabbet, tunnel e groove sul fianco vengono confrontate con possibili feature mirror + -- raccolgo le tasche compatibili if WD.DOUBLE_HEAD_POCKET and - ( - ( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and Proc.AffectedFaces.Front) or - ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' and Proc.AffectedFaces.Front) or - ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Front) or - ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Front) or - ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) - ) then - -- feature vicino al bordo Y- del grezzo - local bIsFeatureOnEdgeOrPocket = false - local nFaceLookingFrontSide - for j = 1, Proc.Fct do - if AreOppositeVectorApprox( Proc.Face[j].VtN, Y_AX()) then - nFaceLookingFrontSide = j - 1 - end - end - local dMaxDist = 200 - if nFaceLookingFrontSide then - local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) - local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) - bIsFeatureOnEdgeOrPocket = dSideDist < dMaxDist - end - -- mirror XY sul lato opposto - local nMirrorId - local dYMirrorAx - local dDeltaZ - local bIsMirrorTowardsBottom = false - -- cerco una possibile feature mirror - for j = 1, #vProc do - local ProcMirror = vProc[j] - if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then - -- feature specchiata rivolta verso Y+ e parallela a X - local bIsMirrorFeatureFacingBackSide = EgtIf( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3', ProcMirror.AffectedFaces.Back and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right, ProcMirror.AffectedFaces.Back) - -- feature specchiata vicino al bordo Y+ del grezzo - local bIsMirrorFeatureOnEdgeOrPocket = false - local nMirrorFaceLookingBackSide - for k = 1, ProcMirror.Fct do - if AreSameVectorApprox( ProcMirror.Face[k].VtN, Y_AX()) then - nMirrorFaceLookingBackSide = k - 1 - end - end - if nMirrorFaceLookingBackSide then - local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingBackSide, GDB_ID.ROOT) - local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY()) - bIsMirrorFeatureOnEdgeOrPocket = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist) - end - -- box delle stesse dimensioni - local bIsMirrorFeatureSameDimension = false - local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and - abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and - abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) - -- box allineati in X - local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5 - -- box che non si intersecano - local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror) - -- distanza minima tra le feature - local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) - local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL - -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni - if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdgeOrPocket and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then - nMirrorId = ProcMirror.Id - local b3Tab = EgtGetTableArea() - local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 - dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() - dDeltaZ = ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ() - bIsMirrorTowardsBottom = ProcMirror.AffectedFaces.Bottom - end - end - end - -- se ho trovato una feature mirror e le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione - if nMirrorId and bIsFeatureOnEdgeOrPocket then - -- 2: specchiatura in Y - Proc.Double = 2 - Proc.MirrorId = nMirrorId - -- posizione Y dell'asse di specchiatura - Proc.MirrorAx = dYMirrorAx - -- Offset Z tra le feature - Proc.MirrorDeltaZ = dDeltaZ - -- se sono groove cieche e la principale guarda su e l'altra guarda giù, la principale va trattata come sidegroove in accordo con la seconda - if ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4') and - Proc.AffectedFaces.Top and bIsMirrorTowardsBottom then - Proc.Stype = 2 - end - end - -- le groove non sul fianco e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio - elseif WD.DOUBLE_HEAD_POCKET and ( - ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) or - ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right)) or - ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top) + ( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and ( Proc.AffectedFaces.Front or Proc.AffectedFaces.Back)) or + ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and ( not Proc.AffectedFaces.Bottom and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right)) or + ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3') or + ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4') or + ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and not Proc.AffectedFaces.Bottom) ) then - table.insert( vGroovesThrough, Proc) - -- i fori verticali e aperti verso Z+ vanno raccolti, ordinati e accoppiati a 2 a 2 per il doppio a parità di X + table.insert( vPockets, Proc) + -- raccolgo i fori verticali e aperti verso Z+ elseif WD.DOUBLE_HEAD_DRILLING and Proc.TopologyLongName == 'DRILLING' then -- recupero e verifico la geometria del foro local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0 @@ -781,24 +695,89 @@ local function SetMirroredFeatures( vProc, b3Raw) end end - -- ordinamento delle feature che vanno accoppiate - -- groove verso Z+ - table.sort( vGroovesThrough, SortFeaturesForMirror) - -- forature verso Z+ + -- ordinamento delle feature raccolte secondo X e poi Y crescente + table.sort( vPockets, SortFeaturesForMirror) table.sort( vDrillings, SortFeaturesForMirror) -- accoppio le groove passanti rivolte verso Z+ - local nCurrentGroove = 1 - while nCurrentGroove <= #vGroovesThrough do - local Proc = vGroovesThrough[nCurrentGroove] + local nCurrentPocket = 1 + while nCurrentPocket <= #vPockets do + local Proc = vPockets[nCurrentPocket] if Proc.Flg ~= 0 then local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local nCurrentMirrorGroove = nCurrentGroove + 1 - while nCurrentMirrorGroove <= #vGroovesThrough do - local ProcMirror = vGroovesThrough[nCurrentMirrorGroove] + local nCurrentMirrorPocket = nCurrentPocket + 1 + while nCurrentMirrorPocket <= #vPockets do + local ProcMirror = vPockets[nCurrentMirrorPocket] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) - -- feature non disattivata e diversa da nCurrentGroove + -- feature non disattivata e diversa da nCurrentPocket local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) + + -- feature mirror della stessa classe topologica + local bIsMirrorTopologyOk = ( Proc.TopologyLongName == ProcMirror.TopologyLongName) + + -- determino se di fianco o in mezzo al singolo pannello + local bLapVsTop = Proc.AffectedFaces.Front and + ( + Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' or + Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or + Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' + ) + + -- distanza della feature master e della feature mirror dal bordo del master panel + local bIsFeatureOnEdge, bIsMirrorFeatureOnEdge = false, false + if bLapVsTop then + local dMaxDistanceFromEdge = 200 + -- feature master Y- + local nFaceLookingFrontSide + for i = 1, Proc.Fct do + if AreOppositeVectorApprox( Proc.Face[i].VtN, Y_AX()) then + nFaceLookingFrontSide = i - 1 + end + end + if nFaceLookingFrontSide then + local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) + local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) + bIsFeatureOnEdge = dSideDist < dMaxDistanceFromEdge + end + -- feature mirror Y+ + local nMirrorFaceLookingFrontSide + for i = 1, ProcMirror.Fct do + if AreSameVectorApprox( ProcMirror.Face[i].VtN, Y_AX()) then + nMirrorFaceLookingFrontSide = i - 1 + end + end + if nMirrorFaceLookingFrontSide then + local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingFrontSide, GDB_ID.ROOT) + local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY()) + bIsMirrorFeatureOnEdge = dMirrorSideDist < dMaxDistanceFromEdge + end + end + + -- se di fianco, si sceglie se le feature sono compatibili con il doppio e nel caso che tipo di lavorazione fare + -- -1: no doppio, 0: nessuna preferenza, 1: pocket, 2: side (scambio faccia principale) + local nDoubleType = 0 + if bLapVsTop and ( Proc.AffectedFaces.Top or Proc.AffectedFaces.Bottom) then + -- side + if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then + nDoubleType = 2 + -- no doppio + elseif Proc.AffectedFaces.Bottom or + ProcMirror.AffectedFaces.Bottom then + nDoubleType = -1 + else + nDoubleType = 1 + end + end + + -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back) or + Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or + Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top + -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = false bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and @@ -812,30 +791,41 @@ local function SetMirroredFeatures( vProc, b3Raw) local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY()) local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL -- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni - if bIsMirrorIdOk and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then + if nDoubleType > -1 and bIsMirrorIdOk and bIsMirrorTopologyOk and bIsMirrorSideOk and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then local dYMirrorAx local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + local dDeltaZ = EgtIf( nDoubleType == 0, ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ(), 0) + -- forzo side o pocket, se necessario + if nDoubleType == 1 then + EgtSetInfo( Proc.Id, 'PCKT', 1) + EgtSetInfo( ProcMirror.Id, 'PCKT', 1) + elseif nDoubleType == 2 then + Proc.Stype = 2 + ProcMirror.Stype = 2 + end -- scrivo i parametri nella lavorazione -- 2: specchiatura in Y Proc.Double = 2 Proc.MirrorId = ProcMirror.Id -- posizione Y dell'asse di specchiatura Proc.MirrorAx = dYMirrorAx + -- Offset Z tra le feature + Proc.MirrorDeltaZ = dDeltaZ -- rimuovo dalla lista le groove già assegnate local ProcMirrorOldId = ProcMirror.Id - table.remove( vGroovesThrough, nCurrentGroove) - -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorGroove - if nCurrentMirrorGroove > #vGroovesThrough or ( vGroovesThrough[nCurrentMirrorGroove].Id ~= ProcMirrorOldId) then nCurrentMirrorGroove = nCurrentMirrorGroove - 1 end - table.remove( vGroovesThrough, nCurrentMirrorGroove) - nCurrentGroove = 0 + table.remove( vPockets, nCurrentPocket) + -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorPocket + if nCurrentMirrorPocket > #vPockets or ( vPockets[nCurrentMirrorPocket].Id ~= ProcMirrorOldId) then nCurrentMirrorPocket = nCurrentMirrorPocket - 1 end + table.remove( vPockets, nCurrentMirrorPocket) + nCurrentPocket = 0 break end - nCurrentMirrorGroove = nCurrentMirrorGroove + 1 + nCurrentMirrorPocket = nCurrentMirrorPocket + 1 end end - nCurrentGroove = nCurrentGroove + 1 + nCurrentPocket = nCurrentPocket + 1 end -- accoppio le forature From 756d58b3e4903c527ef2060e5096f55121a4f749 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 23 Aug 2023 12:24:45 +0200 Subject: [PATCH 17/43] - piccole correzioni a WallExec - in LapJoint -> MakeByPocketing aggiunta forzatura tasche chiuse se la lavorazione potrebbe danneggiare i pezzi limitrofi --- LuaLibs/WFeatureTopology.lua | 2 +- LuaLibs/WProcessLapJoint.lua | 90 ++++++++++++++++++++++++++++++++++++ LuaLibs/WallExec.lua | 11 ++--- 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index afe47bb..ec07b2f 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -157,7 +157,7 @@ local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsPar end --------------------------------------------------------------------- --- risonosce se Proc è una delle topologie standard e, in caso positivo, ne scrive le caratteristiche in campi specifici della Proc stessa restituendo true +-- riconosce se Proc è una delle topologie standard e, in caso positivo, ne scrive le caratteristiche in campi specifici della Proc stessa restituendo true function WFeatureTopology.Classify( Proc) local bRecognized = false local sFamily diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index b04d9ce..513c569 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1326,6 +1326,82 @@ local function MakeByChainSaw( Proc, nFacet, nRawId, b3Raw, dElev, dH, dV) return true end +--------------------------------------------------------------------- +-- restituisce true se la lavorazione potrebbe danneggiare le parti limitrofe; restituisce anche i lati interessati +local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) + local bIsMachiningDamagingOtherParts = false + local vtSidesOverlapped = { Front = false, Back = false, Left = false, Right = false} + -- box esteso in tutte le direzioni + local b3ProcExtended = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + -- box estesi solo nelle rispettive direzioni + local b3ProcExtendedLeft = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + local b3ProcExtendedRight = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + local b3ProcExtendedFront = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + local b3ProcExtendedBack = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + -- punto minimo e massimo assoluti del box + local ptMin = b3ProcExtended:getMin() + local ptMax = b3ProcExtended:getMax() + -- punti di massima estensione dei box delle singole direzioni + local ptLeft = b3ProcExtended:getMin() + local ptRight = b3ProcExtended:getMax() + local ptFront = b3ProcExtended:getMin() + local ptBack = b3ProcExtended:getMax() + -- estensione aggiunta ai box + local dBoxExtensionLength = dMillDiameter / 2 + 10 + -- check box verso X- + if Proc.AffectedFaces.Left then + local vtMove = Vector3d( -dBoxExtensionLength, 0, 0) + ptMin:move( vtMove) + ptLeft:move( vtMove) + b3ProcExtendedLeft:Add( ptLeft) + end + -- check box verso X+ + if Proc.AffectedFaces.Right then + local vtMove = Vector3d( dBoxExtensionLength, 0, 0) + ptMax:move( vtMove) + ptRight:move( vtMove) + b3ProcExtendedRight:Add( ptRight) + end + -- check box verso Y- + if Proc.AffectedFaces.Front then + local vtMove = Vector3d( 0, -dBoxExtensionLength, 0) + ptMin:move( vtMove) + ptFront:move( vtMove) + b3ProcExtendedFront:Add( ptFront) + end + -- check box verso Y+ + if Proc.AffectedFaces.Back then + local vtMove = Vector3d( 0, dBoxExtensionLength, 0) + ptMax:move( vtMove) + ptBack:move( vtMove) + b3ProcExtendedBack:Add( ptBack) + end + -- estendo il box in direzione X e Y e verifico se interseca altre parti + b3ProcExtended:Add( ptMin) + b3ProcExtended:Add( ptMax) + local nPartId = EgtGetFirstPartInRawPart( nRawId) + while nPartId do + local b3Part = EgtGetBBoxGlob( nPartId or GDB_ID.NULL, GDB_BB.STANDARD) + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Part) then + bIsMachiningDamagingOtherParts = true + end + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedLeft, b3Part) then + vtSidesOverlapped.Left = true + end + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedRight, b3Part) then + vtSidesOverlapped.Right = true + end + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedFront, b3Part) then + vtSidesOverlapped.Front = true + end + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedBack, b3Part) then + vtSidesOverlapped.Back = true + end + nPartId = EgtGetNextPartInRawPart( nPartId) + end + return bIsMachiningDamagingOtherParts, vtSidesOverlapped +end + --------------------------------------------------------------------- local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) -- dati della faccia e dell'altra @@ -2247,6 +2323,18 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam end end + -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa + local bForceClosedPocket = false + if WD.AVOID_DAMAGING_OTHER_PARTS then + if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) then + bForceClosedPocket = true + end + if Proc.Double and Proc.Double > 0 then + if IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then + bForceClosedPocket = true + end + end + end -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = WM.AddMachining( Proc, sName, sPocketing) @@ -2288,6 +2376,8 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) sUserNotes = EgtSetValInNotes( sUserNotes, 'DeltaZ', Proc.MirrorDeltaZ) end + -- setto eventuale nota per forzare tasca chiusa + if bForceClosedPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 0) end -- scrivo le note della lavorazione EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 5a00a45..b01db2f 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -672,7 +672,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- raccolgo le tasche compatibili if WD.DOUBLE_HEAD_POCKET and ( - ( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and ( Proc.AffectedFaces.Front or Proc.AffectedFaces.Back)) or + ( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) or ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and ( not Proc.AffectedFaces.Bottom and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right)) or ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3') or ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4') or @@ -699,7 +699,7 @@ local function SetMirroredFeatures( vProc, b3Raw) table.sort( vPockets, SortFeaturesForMirror) table.sort( vDrillings, SortFeaturesForMirror) - -- accoppio le groove passanti rivolte verso Z+ + -- accoppio le tasche local nCurrentPocket = 1 while nCurrentPocket <= #vPockets do local Proc = vPockets[nCurrentPocket] @@ -808,7 +808,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- scrivo i parametri nella lavorazione -- 2: specchiatura in Y Proc.Double = 2 - Proc.MirrorId = ProcMirror.Id + Proc.Mirror = ProcMirror -- posizione Y dell'asse di specchiatura Proc.MirrorAx = dYMirrorAx -- Offset Z tra le feature @@ -861,7 +861,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- scrivo i parametri nella lavorazione -- 2: specchiatura in Y Proc.Double = 2 - Proc.MirrorId = ProcMirror.Id + Proc.Mirror = ProcMirror -- posizione Y dell'asse di specchiatura Proc.MirrorAx = dYMirrorAx -- rimuovo dalla lista le groove già assegnate @@ -944,7 +944,6 @@ function WallExec.ProcessFeatures() ------- -- LAVORAZIONI IN DOPPIO - QUI INSERIRE: - -- ELIMINAZIONE LAVORAZIONI MIRROR IN BASE A SETTAGGIO MACHININGTODELETE IN PROC -- VERIFICA E UPDATE NOTE PER LAVORAZIONI IN CUI SI CONTROLLA SE I PERCORSI SONO SPECCHIATI ------- -- setto quali sono le lavorazioni da disattivare perchè specchiate di lavorazioni in doppio @@ -954,7 +953,7 @@ function WallExec.ProcessFeatures() if Proc.Double and Proc.Double > 0 then for j = 1, #vProc do local ProcMirror = vProc[j] - if Proc.MirrorId == ProcMirror.Id then + if Proc.Mirror.Id == ProcMirror.Id then -- per i fori l'operazione si basa sulla geometria ausiliaria if Proc.TopologyLongName == 'DRILLING' then local AuxId = EgtGetInfo( ProcMirror.Id, 'AUXID', 'i') or 0 From b9c9cc516746938972fe5a11f605b1227b28a82e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 24 Aug 2023 09:53:18 +0200 Subject: [PATCH 18/43] =?UTF-8?q?-=20in=20WallExec=20->=20Collect=20viene?= =?UTF-8?q?=20ora=20calcolata=20e=20scritta=20in=20Proc=20la=20distanza=20?= =?UTF-8?q?dalle=20parti=20vicine,=20nelle=20direzioni=20Y+/Y-/X+/X-,=20tr?= =?UTF-8?q?amite=20la=20funzione=20GetProcessDistanceToNearestParts=20da?= =?UTF-8?q?=20WallLib=20-=20in=20WallExec=20->=20SetMirroredFeatures=20sem?= =?UTF-8?q?plificato=20il=20calcolo=20di=20IsFeatureOnEdge=20-=20in=20LapJ?= =?UTF-8?q?oint=20->=20IsMachiningDamagingOtherParts=20eliminata=20la=20ve?= =?UTF-8?q?rifica=20di=20overlap=20nelle=20singole=20direzioni=20(ora=20gi?= =?UTF-8?q?=C3=A0=20calcolata=20nel=20Collect)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/WProcessLapJoint.lua | 36 ++---------------- LuaLibs/WallExec.lua | 43 +++++----------------- LuaLibs/WallLib.lua | 71 +++++++++++++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 68 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 513c569..488371b 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1330,51 +1330,32 @@ end -- restituisce true se la lavorazione potrebbe danneggiare le parti limitrofe; restituisce anche i lati interessati local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) local bIsMachiningDamagingOtherParts = false - local vtSidesOverlapped = { Front = false, Back = false, Left = false, Right = false} - -- box esteso in tutte le direzioni + -- box da estendere in tutte le direzioni, compreso angolo cieco local b3ProcExtended = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - -- box estesi solo nelle rispettive direzioni - local b3ProcExtendedLeft = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local b3ProcExtendedRight = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local b3ProcExtendedFront = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) - local b3ProcExtendedBack = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) -- punto minimo e massimo assoluti del box local ptMin = b3ProcExtended:getMin() local ptMax = b3ProcExtended:getMax() - -- punti di massima estensione dei box delle singole direzioni - local ptLeft = b3ProcExtended:getMin() - local ptRight = b3ProcExtended:getMax() - local ptFront = b3ProcExtended:getMin() - local ptBack = b3ProcExtended:getMax() -- estensione aggiunta ai box local dBoxExtensionLength = dMillDiameter / 2 + 10 -- check box verso X- if Proc.AffectedFaces.Left then local vtMove = Vector3d( -dBoxExtensionLength, 0, 0) ptMin:move( vtMove) - ptLeft:move( vtMove) - b3ProcExtendedLeft:Add( ptLeft) end -- check box verso X+ if Proc.AffectedFaces.Right then local vtMove = Vector3d( dBoxExtensionLength, 0, 0) ptMax:move( vtMove) - ptRight:move( vtMove) - b3ProcExtendedRight:Add( ptRight) end -- check box verso Y- if Proc.AffectedFaces.Front then local vtMove = Vector3d( 0, -dBoxExtensionLength, 0) ptMin:move( vtMove) - ptFront:move( vtMove) - b3ProcExtendedFront:Add( ptFront) end -- check box verso Y+ if Proc.AffectedFaces.Back then local vtMove = Vector3d( 0, dBoxExtensionLength, 0) ptMax:move( vtMove) - ptBack:move( vtMove) - b3ProcExtendedBack:Add( ptBack) end -- estendo il box in direzione X e Y e verifico se interseca altre parti b3ProcExtended:Add( ptMin) @@ -1385,21 +1366,10 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Part) then bIsMachiningDamagingOtherParts = true end - if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedLeft, b3Part) then - vtSidesOverlapped.Left = true - end - if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedRight, b3Part) then - vtSidesOverlapped.Right = true - end - if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedFront, b3Part) then - vtSidesOverlapped.Front = true - end - if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtendedBack, b3Part) then - vtSidesOverlapped.Back = true - end nPartId = EgtGetNextPartInRawPart( nPartId) end - return bIsMachiningDamagingOtherParts, vtSidesOverlapped + + return bIsMachiningDamagingOtherParts end --------------------------------------------------------------------- diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index b01db2f..55a4b2b 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -196,6 +196,9 @@ function WallExec.CollectFeatures( PartId, b3Raw) -- recupero l'elenco delle facce della parte interessate dalla feature Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) + -- recupero le distanze tra la feature e le altre parti più vicine + Proc.DistanceToNearestParts = WL.GetProcessDistanceToNearestParts( Proc) + -- recupero informazioni sulle facce della feature Proc.Face = {} for i = 1, Proc.Fct do @@ -666,6 +669,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local vPockets = {} local vDrillings = {} + -- raccolgo le feature compatibili con doppio for i = 1, #vProc do local Proc = vProc[i] if Proc.Flg ~= 0 then @@ -711,10 +715,8 @@ local function SetMirroredFeatures( vProc, b3Raw) local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) -- feature non disattivata e diversa da nCurrentPocket local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) - -- feature mirror della stessa classe topologica local bIsMirrorTopologyOk = ( Proc.TopologyLongName == ProcMirror.TopologyLongName) - -- determino se di fianco o in mezzo al singolo pannello local bLapVsTop = Proc.AffectedFaces.Front and ( @@ -724,37 +726,12 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' ) - - -- distanza della feature master e della feature mirror dal bordo del master panel + -- se di fianco, determino se è l'ultima parte prima della fine del grezzo local bIsFeatureOnEdge, bIsMirrorFeatureOnEdge = false, false if bLapVsTop then - local dMaxDistanceFromEdge = 200 - -- feature master Y- - local nFaceLookingFrontSide - for i = 1, Proc.Fct do - if AreOppositeVectorApprox( Proc.Face[i].VtN, Y_AX()) then - nFaceLookingFrontSide = i - 1 - end - end - if nFaceLookingFrontSide then - local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT) - local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY()) - bIsFeatureOnEdge = dSideDist < dMaxDistanceFromEdge - end - -- feature mirror Y+ - local nMirrorFaceLookingFrontSide - for i = 1, ProcMirror.Fct do - if AreSameVectorApprox( ProcMirror.Face[i].VtN, Y_AX()) then - nMirrorFaceLookingFrontSide = i - 1 - end - end - if nMirrorFaceLookingFrontSide then - local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingFrontSide, GDB_ID.ROOT) - local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY()) - bIsMirrorFeatureOnEdge = dMirrorSideDist < dMaxDistanceFromEdge - end + bIsFeatureOnEdge = Proc.DistanceToNearestParts.Front > b3Raw:getDimY() + bIsMirrorFeatureOnEdge = ProcMirror.DistanceToNearestParts.Back > b3Raw:getDimY() end - -- se di fianco, si sceglie se le feature sono compatibili con il doppio e nel caso che tipo di lavorazione fare -- -1: no doppio, 0: nessuna preferenza, 1: pocket, 2: side (scambio faccia principale) local nDoubleType = 0 @@ -763,21 +740,18 @@ local function SetMirroredFeatures( vProc, b3Raw) if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then nDoubleType = 2 -- no doppio - elseif Proc.AffectedFaces.Bottom or - ProcMirror.AffectedFaces.Bottom then + elseif Proc.AffectedFaces.Bottom or ProcMirror.AffectedFaces.Bottom then nDoubleType = -1 else nDoubleType = 1 end end - -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top - -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = false bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and @@ -858,6 +832,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + -- scrivo i parametri nella lavorazione -- 2: specchiatura in Y Proc.Double = 2 diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index f163bbb..990ba0a 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -401,7 +401,7 @@ function WallLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId) end ------------------------------------------------------------------------------------------------------------- --- restituisce le facce del grezzo interessate dalla feature Proc +-- restituisce le facce della parte interessate dalla feature Proc function WallLib.GetProcessAffectedFaces( Proc) local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') local b3Part = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) @@ -430,5 +430,74 @@ function WallLib.GetProcessAffectedFaces( Proc) return vtFacesAffected end +------------------------------------------------------------------------------------------------------------- +-- restituisce le distanze XY tra la feature Proc e le altre parti più vicine, secondo le direzioni Y+/Y-/X+/X- +function WallLib.GetProcessDistanceToNearestParts( Proc) + local b3Proc = Proc.Box + local ptMinProc = b3Proc:getMin() + local ptMaxProc = b3Proc:getMax() + local vtDistances = { Front = 0, Back = 0, Left = 0, Right = 0} + if Proc.AffectedFaces.Front then + vtDistances.Front = GEO.INFINITO + end + if Proc.AffectedFaces.Back then + vtDistances.Back = GEO.INFINITO + end + if Proc.AffectedFaces.Left then + vtDistances.Left = GEO.INFINITO + end + if Proc.AffectedFaces.Right then + vtDistances.Right = GEO.INFINITO + end + local nRawId = EgtGetFirstRawPart() + local nPartId = EgtGetFirstPartInRawPart( nRawId) + while nPartId do + if Proc.PartId ~= nPartId then + local b3Part = EgtGetBBoxGlob( nPartId or GDB_ID.NULL, GDB_BB.STANDARD) + local ptMinPart = b3Part:getMin() + local ptMaxPart = b3Part:getMax() + if Proc.AffectedFaces.Front then + if OverlapsXY( b3Proc, b3Part) then + vtDistances.Front = 0 + elseif OverlapsX( b3Proc, b3Part) then + if ptMaxPart:getY() < ptMinProc:getY() + 100 * GEO.EPS_SMALL then + vtDistances.Front = min( vtDistances.Front, max( 0, ptMinProc:getY() - ptMaxPart:getY())) + end + end + end + if Proc.AffectedFaces.Back then + if OverlapsXY( b3Proc, b3Part) then + vtDistances.Back = 0 + elseif OverlapsX( b3Proc, b3Part) then + if ptMaxProc:getY() < ptMinPart:getY() + 100 * GEO.EPS_SMALL then + vtDistances.Back = min( vtDistances.Back, max( 0, ptMinPart:getY() - ptMaxProc:getY())) + end + end + end + if Proc.AffectedFaces.Left then + if OverlapsXY( b3Proc, b3Part) then + vtDistances.Left = 0 + elseif OverlapsY( b3Proc, b3Part) then + if ptMaxPart:getX() < ptMinProc:getX() + 100 * GEO.EPS_SMALL then + vtDistances.Left = min( vtDistances.Left, max( 0, ptMinProc:getX() - ptMaxPart:getX())) + end + end + end + if Proc.AffectedFaces.Right then + if OverlapsXY( b3Proc, b3Part) then + vtDistances.Right = 0 + elseif OverlapsY( b3Proc, b3Part) then + if ptMaxProc:getX() < ptMinPart:getX() + 100 * GEO.EPS_SMALL then + vtDistances.Right = min( vtDistances.Right, max( 0, ptMinPart:getX() - ptMaxProc:getX())) + end + end + end + end + nPartId = EgtGetNextPartInRawPart( nPartId) + end + + return vtDistances +end + ------------------------------------------------------------------------------------------------------------- return WallLib From 3c7c22ae7c7ef1036bcf6f960b176416c3e0a505 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 24 Aug 2023 16:05:42 +0200 Subject: [PATCH 19/43] - in WallLib aggiunta la funzione GetProcessDistanceToRawPart - alcune correzioni in WallExec --- LuaLibs/WallExec.lua | 27 +++++++++++++++++---------- LuaLibs/WallLib.lua | 21 ++++++++++++++++++++- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 55a4b2b..ada9b5a 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -192,17 +192,22 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc.TaskId = nTaskId Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) Proc.IsOutline = ( Proc.Prc == 251 or Proc.Prc == 252) + + if b3Raw then + -- recupero l'elenco delle facce della parte interessate dalla feature + Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) - -- recupero l'elenco delle facce della parte interessate dalla feature - Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) + -- recupero le distanze tra la feature e le altre parti più vicine + Proc.DistanceToNearestParts = WL.GetProcessDistanceToNearestParts( Proc) + + -- recupero le distanze tra la feature e il grezzo + Proc.DistanceToRawPart = WL.GetProcessDistanceToRawPart( Proc, b3Raw) - -- recupero le distanze tra la feature e le altre parti più vicine - Proc.DistanceToNearestParts = WL.GetProcessDistanceToNearestParts( Proc) - - -- recupero informazioni sulle facce della feature - Proc.Face = {} - for i = 1, Proc.Fct do - Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ), Elevation = WL.GetFaceElevation( Proc.Id, i - 1, PartId)} + -- recupero informazioni sulle facce della feature + Proc.Face = {} + for i = 1, Proc.Fct do + Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ), Elevation = WL.GetFaceElevation( Proc.Id, i - 1, PartId)} + end end if Proc.Box and not Proc.Box:isEmpty() then @@ -738,7 +743,9 @@ local function SetMirroredFeatures( vProc, b3Raw) if bLapVsTop and ( Proc.AffectedFaces.Top or Proc.AffectedFaces.Bottom) then -- side if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then - nDoubleType = 2 + if not ( Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top) then + nDoubleType = 2 + end -- no doppio elseif Proc.AffectedFaces.Bottom or ProcMirror.AffectedFaces.Bottom then nDoubleType = -1 diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index 990ba0a..d78e493 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -431,7 +431,7 @@ function WallLib.GetProcessAffectedFaces( Proc) end ------------------------------------------------------------------------------------------------------------- --- restituisce le distanze XY tra la feature Proc e le altre parti più vicine, secondo le direzioni Y+/Y-/X+/X- +-- restituisce le distanze XY tra la feature Proc e le altre parti più vicine, secondo le direzioni Y-/Y+/X-/X+ function WallLib.GetProcessDistanceToNearestParts( Proc) local b3Proc = Proc.Box local ptMinProc = b3Proc:getMin() @@ -499,5 +499,24 @@ function WallLib.GetProcessDistanceToNearestParts( Proc) return vtDistances end +------------------------------------------------------------------------------------------------------------- +-- restituisce le distanze XY tra la feature Proc e il grezzo, secondo le direzioni Y-/Y+/X-/X+ +function WallLib.GetProcessDistanceToRawPart( Proc, b3Raw) + local b3Proc = Proc.Box + local ptMinProc = b3Proc:getMin() + local ptMaxProc = b3Proc:getMax() + local ptMinRaw = b3Raw:getMin() + local ptMaxRaw = b3Raw:getMax() + local vtDistances = { Front = GEO.INFINITO, Back = GEO.INFINITO, Left = GEO.INFINITO, Right = GEO.INFINITO} + if EnclosesXY( b3Raw, b3Proc) then + vtDistances.Front = max( 0, ptMinProc:getY() - ptMinRaw:getY()) + vtDistances.Back = max( 0, ptMaxRaw:getY() - ptMaxProc:getY()) + vtDistances.Left = max( 0, ptMinProc:getX() - ptMinRaw:getX()) + vtDistances.Right = max( 0, ptMaxRaw:getX() - ptMaxProc:getX()) + end + + return vtDistances +end + ------------------------------------------------------------------------------------------------------------- return WallLib From 9d812ab33a6c1f62256acf1a7b8888c3da09e521 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 24 Aug 2023 17:08:39 +0200 Subject: [PATCH 20/43] =?UTF-8?q?-=20in=20LapJoint=20->=20MakeByPocketing,?= =?UTF-8?q?=20se=20doppio,=20escludo=20ottimizzazioni=20e=20forzo=20attacc?= =?UTF-8?q?o=20interno=20perch=C3=A8=20la=20tasca=20specchiata=20potrebbe?= =?UTF-8?q?=20essere=20nel=20mezzo=20del=20pannello?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/WProcessLapJoint.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 488371b..f90a9d1 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -2345,6 +2345,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', Proc.Double) sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', Proc.MirrorAx) sUserNotes = EgtSetValInNotes( sUserNotes, 'DeltaZ', Proc.MirrorDeltaZ) + -- escludo ottimizzazioni e forzo attacco interno perchè la tasca specchiata potrebbe essere nel mezzo del pannello + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxOptSize', 0.1) + EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT) end -- setto eventuale nota per forzare tasca chiusa if bForceClosedPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 0) end From 924313a0ea7fce74f36970c9a14a17cd6317a5f8 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 24 Aug 2023 18:40:00 +0200 Subject: [PATCH 21/43] - alcune correzioni --- LuaLibs/WProcessLapJoint.lua | 2 +- LuaLibs/WallExec.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index f90a9d1..4b1bc55 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1327,7 +1327,7 @@ local function MakeByChainSaw( Proc, nFacet, nRawId, b3Raw, dElev, dH, dV) end --------------------------------------------------------------------- --- restituisce true se la lavorazione potrebbe danneggiare le parti limitrofe; restituisce anche i lati interessati +-- restituisce true se la lavorazione potrebbe danneggiare le parti limitrofe local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) local bIsMachiningDamagingOtherParts = false -- box da estendere in tutte le direzioni, compreso angolo cieco diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index ada9b5a..c1f3c1e 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -754,7 +754,7 @@ local function SetMirroredFeatures( vProc, b3Raw) end end -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo - local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back) or + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge ) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or @@ -777,7 +777,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() - local dDeltaZ = EgtIf( nDoubleType == 0, ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ(), 0) + local dDeltaZ = ProcMirror.Box:getMax():getZ() - Proc.Box:getMax():getZ() -- forzo side o pocket, se necessario if nDoubleType == 1 then EgtSetInfo( Proc.Id, 'PCKT', 1) From afb33aa7c635611d989cd927a47dfbaaded5abd7 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 29 Aug 2023 13:12:34 +0200 Subject: [PATCH 22/43] - in WallLib -> GetProcessDistanceToNearestParts piccole correzioni al calcolo del solido della parte - in LapJoint -> MakeByPocketing migliorata la scelta utensile e la forzatura tasca chiusa nel caso di parti vicine --- LuaLibs/WProcessLapJoint.lua | 146 ++++++++++++++++++++++++----------- LuaLibs/WallLib.lua | 24 +++--- 2 files changed, 114 insertions(+), 56 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 4b1bc55..380f8a5 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1362,8 +1362,10 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) b3ProcExtended:Add( ptMax) local nPartId = EgtGetFirstPartInRawPart( nRawId) while nPartId do - local b3Part = EgtGetBBoxGlob( nPartId or GDB_ID.NULL, GDB_BB.STANDARD) - if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Part) then + local nBoxSolidId = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( nBoxSolidId or GDB_ID.NULL, GDB_BB.STANDARD) + b3Solid:expand( - 10 * GEO.EPS_SMALL) + if ( nPartId ~= Proc.PartId) and OverlapsXY( b3ProcExtended, b3Solid) then bIsMachiningDamagingOtherParts = true end nPartId = EgtGetNextPartInRawPart( nPartId) @@ -2220,6 +2222,97 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d return true, sWarn end +--------------------------------------------------------------------- +local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) + local dStartDiameter = dMaxDiameter + if Proc.AffectedFaces.Front then + dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Front) + end + if Proc.AffectedFaces.Back then + dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Back) + end + if Proc.AffectedFaces.Left then + dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Left) + end + if Proc.AffectedFaces.Right then + dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Right) + end + + local bForceClosedPocket = false + -- recupero la lavorazione + local bUseDElevToFindPocketing = true + local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev) + -- se tasca troppo profonda cerco senza elevazione e limiterò la profondità + if not sPocketing then + bUseDElevToFindPocketing = false + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter) + end + local dMillDiam = 20 + local dMaxDepth = 0 + local dThDiam = 100 + local sTuuid + -- se lavorazione trovata verifico eventuale doppio, raccolgo i dati utensile e verifico collisioni dell'utensile con altre parti + if sPocketing then + -- se doppio cerco una lavorazione adatta + if Proc.Double and Proc.Double == 2 then + local sPocketingBackup = sPocketing + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') + if not IsMachiningOkForDouble( sPocketing) then + Proc.Double = 0 + sPocketing = sPocketingBackup + end + end + -- recupero diametro utensile + if EgtMdbSetCurrMachining( sPocketing) then + sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + end + end + -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa + if WD.AVOID_DAMAGING_OTHER_PARTS then + if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or + Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then + bForceClosedPocket = true + end + end + -- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa + else + bForceClosedPocket = true + end + + -- se tasca chiusa cerco lavorazione con diametro massimo pari a dimensione tasca e riverifico per eventuale doppio + if bForceClosedPocket then + dMaxDiameter = min( dH, dV) + bUseDElevToFindPocketing = true + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev) + if not sPocketing then + bUseDElevToFindPocketing = false + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter) + end + -- se doppio cerco una lavorazione adatta + if Proc.Double and Proc.Double == 2 then + local sPocketingBackup = sPocketing + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') + if not IsMachiningOkForDouble( sPocketing) then + Proc.Double = 0 + sPocketing = sPocketingBackup + end + end + end + + -- recupero dati utensile + if EgtMdbSetCurrMachining( sPocketing) then + sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam + dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) or dMaxDepth + dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam + end + end + + return sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam +end --------------------------------------------------------------------- local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) -- dati della faccia @@ -2260,51 +2353,14 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) elseif Proc.Fct >= 4 then dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) end - -- recupero la lavorazione - local bUseDElevToFindPocketing = true - local sPocketing = WM.FindPocketing( 'Pocket', dDiam, dElev) + + local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV) if not sPocketing then - bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dDiam) - if not sPocketing then - local sErr = 'Error : pocketing not found in library' - EgtOutLog( sErr) - return false, sErr - end - end - if Proc.Double and Proc.Double == 2 then - local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dDiam, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') - if not IsMachiningOkForDouble( sPocketing) then - Proc.Double = 0 - sPocketing = sPocketingBackup - end - end - -- recupero i dati dell'utensile - local dMillDiam = 20 - local dMaxDepth = 0 - local dThDiam = 100 - local sTuuid - if EgtMdbSetCurrMachining( sPocketing) then - sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) - if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then - dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam - dMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) or dMaxDepth - dThDiam = EgtTdbGetCurrToolThDiam() or dThDiam - end - end - -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa - local bForceClosedPocket = false - if WD.AVOID_DAMAGING_OTHER_PARTS then - if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) then - bForceClosedPocket = true - end - if Proc.Double and Proc.Double > 0 then - if IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then - bForceClosedPocket = true - end - end + local sErr = 'Error : pocketing not found in library' + EgtOutLog( sErr) + return false, sErr end + -- inserisco la lavorazione di svuotatura local sName = 'Pock_' .. ( EgtGetName( Proc.Id) or tostring( Proc.Id)) local nMchFId = WM.AddMachining( Proc, sName, sPocketing) diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index d78e493..ac1b5b7 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -453,40 +453,42 @@ function WallLib.GetProcessDistanceToNearestParts( Proc) local nPartId = EgtGetFirstPartInRawPart( nRawId) while nPartId do if Proc.PartId ~= nPartId then - local b3Part = EgtGetBBoxGlob( nPartId or GDB_ID.NULL, GDB_BB.STANDARD) - local ptMinPart = b3Part:getMin() - local ptMaxPart = b3Part:getMax() + local nBoxSolidId = EgtGetFirstNameInGroup( nPartId, 'Box') + local b3Solid = EgtGetBBoxGlob( nBoxSolidId or GDB_ID.NULL, GDB_BB.STANDARD) + b3Solid:expand( - 10 * GEO.EPS_SMALL) + local ptMinPart = b3Solid:getMin() + local ptMaxPart = b3Solid:getMax() if Proc.AffectedFaces.Front then - if OverlapsXY( b3Proc, b3Part) then + if OverlapsXY( b3Proc, b3Solid) then vtDistances.Front = 0 - elseif OverlapsX( b3Proc, b3Part) then + elseif OverlapsX( b3Proc, b3Solid) then if ptMaxPart:getY() < ptMinProc:getY() + 100 * GEO.EPS_SMALL then vtDistances.Front = min( vtDistances.Front, max( 0, ptMinProc:getY() - ptMaxPart:getY())) end end end if Proc.AffectedFaces.Back then - if OverlapsXY( b3Proc, b3Part) then + if OverlapsXY( b3Proc, b3Solid) then vtDistances.Back = 0 - elseif OverlapsX( b3Proc, b3Part) then + elseif OverlapsX( b3Proc, b3Solid) then if ptMaxProc:getY() < ptMinPart:getY() + 100 * GEO.EPS_SMALL then vtDistances.Back = min( vtDistances.Back, max( 0, ptMinPart:getY() - ptMaxProc:getY())) end end end if Proc.AffectedFaces.Left then - if OverlapsXY( b3Proc, b3Part) then + if OverlapsXY( b3Proc, b3Solid) then vtDistances.Left = 0 - elseif OverlapsY( b3Proc, b3Part) then + elseif OverlapsY( b3Proc, b3Solid) then if ptMaxPart:getX() < ptMinProc:getX() + 100 * GEO.EPS_SMALL then vtDistances.Left = min( vtDistances.Left, max( 0, ptMinProc:getX() - ptMaxPart:getX())) end end end if Proc.AffectedFaces.Right then - if OverlapsXY( b3Proc, b3Part) then + if OverlapsXY( b3Proc, b3Solid) then vtDistances.Right = 0 - elseif OverlapsY( b3Proc, b3Part) then + elseif OverlapsY( b3Proc, b3Solid) then if ptMaxProc:getX() < ptMinPart:getX() + 100 * GEO.EPS_SMALL then vtDistances.Right = min( vtDistances.Right, max( 0, ptMinPart:getX() - ptMaxProc:getX())) end From 5524fbf0cbc9247925fa3245426016c3e7b5670d Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 30 Aug 2023 12:09:08 +0200 Subject: [PATCH 23/43] - spostate funzioni per verifica lavorazione adatta a doppio in MachiningLib - aggiunte (commentate per ora) prime righe per riconoscimento percorsi fresature da specchiare --- LuaLibs/WMachiningLib.lua | 50 ++++++++++++++++++++++++++ LuaLibs/WProcessLapJoint.lua | 68 ++++++------------------------------ LuaLibs/WallExec.lua | 15 +++++++- 3 files changed, 74 insertions(+), 59 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index e492b59..c042091 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -199,5 +199,55 @@ function WMachiningLib.AddMachining( Proc, sName, sMachining) return nMchId, sFinalName end +--------------------------------------------------------------------- +local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) + local bIsToolDoubleOk = false + -- dimensioni utensile master + EgtTdbSetCurrTool( sToolMasterName) + local bIsBlade = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false + local dTMaxMat = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) + local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth()) + local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0 + local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) + -- dimensioni utensile double + EgtTdbSetCurrTool( sToolDoubleName) + local bIsBladeDouble = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false + local dTMaxMatDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) + local dTMaxDepthDouble = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMatDouble, EgtTdbGetCurrToolMaxDepth()) + local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0 + local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) + -- controllo che siano uguali + bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and + ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and + ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and + ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and + ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and + ( bTipFeed == bTipFeedDouble) and + ( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and + EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + return bIsToolDoubleOk +end + +--------------------------------------------------------------------- +function WMachiningLib.IsMachiningOkForDouble( sMachining) + local bDoubleOk = false + if sMachining and EgtMdbSetCurrMachining( sMachining) then + -- recupero l'utensile della lavorazione + local sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL) + if EgtTdbSetCurrTool( sToolMasterName or '') then + -- cerco eventuale utensile in doppio + local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') + if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then + bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName) + end + end + end + return bDoubleOk +end + ------------------------------------------------------------------------------------------------------------- return WMachiningLib diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 380f8a5..5061573 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -735,56 +735,6 @@ local function MakeLocalSurf( ptP1, ptP2, ptP3, nAddGrpId) return nidFace end ---------------------------------------------------------------------- -local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) - local bIsToolDoubleOk = false - -- dimensioni utensile master - EgtTdbSetCurrTool( sToolMasterName) - local bIsBlade = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false - local dTMaxMat = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) - local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth()) - local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0 - local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 - local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) - -- dimensioni utensile double - EgtTdbSetCurrTool( sToolDoubleName) - local bIsBladeDouble = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false - local dTMaxMatDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.THICK), EgtTdbGetCurrToolParam( MCH_TP.MAXMAT)) - local dTMaxDepthDouble = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMatDouble, EgtTdbGetCurrToolMaxDepth()) - local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0 - local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 - local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) - -- controllo che siano uguali - bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and - ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and - ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and - ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and - ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and - ( bTipFeed == bTipFeedDouble) and - ( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and - EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) - return bIsToolDoubleOk -end - ---------------------------------------------------------------------- -local function IsMachiningOkForDouble( sMachining) - local bDoubleOk = false - if sMachining and EgtMdbSetCurrMachining( sMachining) then - -- recupero l'utensile della lavorazione - local sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL) - if EgtTdbSetCurrTool( sToolMasterName or '') then - -- cerco eventuale utensile in doppio - local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') - if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then - bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName) - end - end - end - return bDoubleOk -end - --------------------------------------------------------------------- local function AddMillCornerMachining( nPartId, nNewProc, nFacInd, tFacAdj, nTypeConeCut, nAddGrpId, dToolDiam, dThick, sMilling, dOffsAng, dDepthMach, @@ -1387,7 +1337,7 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) if Proc.Double and Proc.Double == 2 then local sMillingBackup = sMilling sMilling = WM.FindMilling( 'Side', nil, nil, nil, nil, nil, nil, nil, 'H1') - if not IsMachiningOkForDouble( sMilling) then + if not WL.IsMachiningOkForDouble( sMilling) then Proc.Double = 0 sMilling = sMillingBackup end @@ -1505,7 +1455,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMilling sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, nil, 'H1') - if not IsMachiningOkForDouble( sMilling) then + if not WL.IsMachiningOkForDouble( sMilling) then Proc.Double = 0 sMilling = sMillOnSideBackup end @@ -2223,6 +2173,8 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d end --------------------------------------------------------------------- +-- trova la migliore lavorazione tasca in base a diametro utensile, elevazione, doppio e eventuale interferenza di parti vicine +-- se necessario forza la tasca a chiusa local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) local dStartDiameter = dMaxDiameter if Proc.AffectedFaces.Front then @@ -2257,7 +2209,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') - if not IsMachiningOkForDouble( sPocketing) then + if not WL.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup end @@ -2294,7 +2246,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') - if not IsMachiningOkForDouble( sPocketing) then + if not WL.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup end @@ -2302,7 +2254,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) end -- recupero dati utensile - if EgtMdbSetCurrMachining( sPocketing) then + if sPocketing and EgtMdbSetCurrMachining( sPocketing) then sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam @@ -2545,7 +2497,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev, 'H1') - if IsMachiningOkForDouble( sMillOnSide) then + if WL.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup @@ -2801,7 +2753,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, min( dH, dV), nil, dSideElev, 'H1') - if IsMachiningOkForDouble( sMillOnSide) then + if WL.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup @@ -2863,7 +2815,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElevMultiplier * dSideElev, 'H1') - if IsMachiningOkForDouble( sMillOnSide) then + if WL.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index c1f3c1e..f64fc38 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -928,6 +928,7 @@ function WallExec.ProcessFeatures() -- LAVORAZIONI IN DOPPIO - QUI INSERIRE: -- VERIFICA E UPDATE NOTE PER LAVORAZIONI IN CUI SI CONTROLLA SE I PERCORSI SONO SPECCHIATI ------- + -- setto quali sono le lavorazioni da disattivare perchè specchiate di lavorazioni in doppio local vProcToDisable = {} for i = 1, #vProc do @@ -949,6 +950,7 @@ function WallExec.ProcessFeatures() end end end + -- cancello le operazioni legate a lavorazioni specchiate local nOperId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) while nOperId do @@ -968,6 +970,17 @@ function WallExec.ProcessFeatures() nOperId = EgtGetNextOperation( nOperId) end end + +-- -- verifico le fresature da specchiare +-- local nClId = EgtGetFirstNameInGroup( nOperId, 'CL') +-- local nPathId = EgtGetFirstInGroup( nClId or GDB_ID.NULL) +-- local vtTool = EgtGetInfo( nPathId, 'EXTR', 'v') +-- local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') +-- local ptMax = EgtGetInfo( nClId, 'MMAX', 'p') +-- local b3Operation = BBox3d( ptMin, ptMax) +-- local sMachining = EgtGetMachiningParam( MCH_MP.NAME, 's') + + -- se macchina pareti if not WD.BEAM_MACHINE then -- riordino le lavorazioni tra tutti i pezzi @@ -979,7 +992,7 @@ function WallExec.ProcessFeatures() local nGetPriorityFromBtl = WD.BTL_PRIORITY or 0 if nGetPriorityFromBtl > 0 then local vPriority = {} - local nOperId = EgtGetNextOperation( PrevMch) + nOperId = EgtGetNextOperation( PrevMch) local nCurrentPriorityId = 1 while nOperId do local nPriority = EgtGetInfo( nOperId or GDB_ID.NULL, 'PRIORITY', 'i') From d24a86bcddcf0b6be05842da351c98ae0f615f6c Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 30 Aug 2023 18:21:10 +0200 Subject: [PATCH 24/43] - aggiunta ricerca e esecuzione di fresature in doppio da percorso specchiato - piccole correzioni --- LuaLibs/WProcessLapJoint.lua | 16 +++--- LuaLibs/WallExec.lua | 95 ++++++++++++++++++++++++++++++------ 2 files changed, 89 insertions(+), 22 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 5061573..5fa38d1 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1337,7 +1337,7 @@ local function MakeByMill( Proc, nFacet, nOthFac, nRawId, b3Raw, dSideDist) if Proc.Double and Proc.Double == 2 then local sMillingBackup = sMilling sMilling = WM.FindMilling( 'Side', nil, nil, nil, nil, nil, nil, nil, 'H1') - if not WL.IsMachiningOkForDouble( sMilling) then + if not WM.IsMachiningOkForDouble( sMilling) then Proc.Double = 0 sMilling = sMillingBackup end @@ -1455,7 +1455,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMilling sMilling = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, nil, 'H1') - if not WL.IsMachiningOkForDouble( sMilling) then + if not WM.IsMachiningOkForDouble( sMilling) then Proc.Double = 0 sMilling = sMillOnSideBackup end @@ -2209,7 +2209,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') - if not WL.IsMachiningOkForDouble( sPocketing) then + if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup end @@ -2246,7 +2246,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') - if not WL.IsMachiningOkForDouble( sPocketing) then + if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup end @@ -2305,7 +2305,7 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) elseif Proc.Fct >= 4 then dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) end - + -- cerco lavorazione adatta e recupero i dati utensile local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV) if not sPocketing then local sErr = 'Error : pocketing not found in library' @@ -2497,7 +2497,7 @@ local function MakeTwoFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, dMaxThick, nil, dMinSideElev, 'H1') - if WL.IsMachiningOkForDouble( sMillOnSide) then + if WM.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup @@ -2753,7 +2753,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideMill', nil, nil, nil, nil, min( dH, dV), nil, dSideElev, 'H1') - if WL.IsMachiningOkForDouble( sMillOnSide) then + if WM.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup @@ -2815,7 +2815,7 @@ local function MakeMoreFaces( Proc, nRawId, b3Raw) if Proc.Double and Proc.Double == 2 then local sMillOnSideBackup = sMillOnSide sMillOnSide = WM.FindMilling( 'SideGroove', nil, nil, nil, nil, min( dH, dV), nil, dSideElevMultiplier * dSideElev, 'H1') - if WL.IsMachiningOkForDouble( sMillOnSide) then + if WM.IsMachiningOkForDouble( sMillOnSide) then bDoubleMillOnSide = true else sMillOnSide = sMillOnSideBackup diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index f64fc38..3e45b29 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -670,6 +670,7 @@ end -- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri local function SetMirroredFeatures( vProc, b3Raw) + -- interasse minimo local dMinimumDistanceMirroredFeatures = 780 local vPockets = {} local vDrillings = {} @@ -760,8 +761,7 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top -- box delle stesse dimensioni - local bIsMirrorFeatureSameDimension = false - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + local bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box allineati in X @@ -822,8 +822,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- feature non disattivata e diversa da nCurrentDrilling local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0) -- box delle stesse dimensioni - local bIsMirrorFeatureSameDimension = false - bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and + local bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) -- box allineati in X @@ -862,6 +861,82 @@ local function SetMirroredFeatures( vProc, b3Raw) end end +------------------------------------------------------------------------------------------------------------- +-- verifico e imposto le fresature da specchiare +local function SetMirroredOperations() + -- interasse minimo + local dMinimumDistanceMirroredOperations = 780 + local nOperIdMaster = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + while nOperIdMaster do + EgtSetCurrMachining( nOperIdMaster) + local nClId = EgtGetFirstNameInGroup( nOperIdMaster, 'CL') + local nPathId = EgtGetFirstInGroup( nClId or GDB_ID.NULL) + -- vettore direzione utensile lavorazione master + local vtTool = EgtGetInfo( nPathId, 'EXTR', 'v') + local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') + local ptMax = EgtGetInfo( nClId, 'MMAX', 'p') + -- box percorso lavorazione master + local b3Operation = BBox3d( ptMin, ptMax) + local sMachining = EgtGetMachiningParam( MCH_MP.NAME, 's') + -- lavorazione master adatta alla specchiatura + local bIsMachiningOk = ( EgtGetMachiningParam( MCH_MP.TYPE) == MCH_OY.MILLING) and EgtGetOperationMode( nOperIdMaster) and WM.IsMachiningOkForDouble( sMachining) + local nOperIdMirror = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + if bIsMachiningOk then + while nOperIdMirror do + EgtSetCurrMachining( nOperIdMirror) + local nClIdMirror = EgtGetFirstNameInGroup( nOperIdMirror, 'CL') + local nPathIdMirror = EgtGetFirstInGroup( nClIdMirror or GDB_ID.NULL) + -- vettore direzione utensile lavorazione mirror + local vtToolMirror = EgtGetInfo( nPathIdMirror, 'EXTR', 'v') + local ptMinMirror = EgtGetInfo( nClIdMirror, 'MMIN', 'p') + local ptMaxMirror = EgtGetInfo( nClIdMirror, 'MMAX', 'p') + -- box percorso lavorazione mirror + local b3OperationMirror = BBox3d( ptMinMirror, ptMaxMirror) + -- lavorazione mirror adatta alla specchiatura + local bIsMirrorMachiningOk = ( EgtGetMachiningParam( MCH_MP.TYPE) == MCH_OY.MILLING) and EgtGetOperationMode( nOperIdMirror) and nOperIdMaster ~= nOperIdMirror + -- lavorazione master più a sinistra + local bIsMirrorSideOk = ( b3OperationMirror:getCenter():getY() - b3Operation:getCenter():getY()) > ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) + -- box delle stesse dimensioni + local bIsMirrorOperationSameDimension = abs( b3Operation:getDimX() - b3OperationMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Operation:getDimY() - b3OperationMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Operation:getDimZ() - b3OperationMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) + -- box allineati in X + local bIsMirrorBoxXAligned = abs( b3Operation:getCenter():getX() - b3OperationMirror:getCenter():getX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and + abs( b3Operation:getCenter():getX() - b3OperationMirror:getCenter():getX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) + -- box che non si intersecano + local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Operation, b3OperationMirror) + -- distanza minima tra le feature + local dYMinDistance = max( b3Operation:getMin():getY(), b3OperationMirror:getMin():getY()) - min( b3Operation:getMax():getY(), b3OperationMirror:getMax():getY()) + local bIsMirrorOperationDistanceOk = dYMinDistance > dMinimumDistanceMirroredOperations + 10 * GEO.EPS_SMALL + -- vettori utensile specchiati + vtTool:mirror( Y_AX()) + local bIsMirrorVectorOk = AreSameVectorApprox( vtTool, vtToolMirror) + -- se condizioni corrette, scrivo le note e cancello la specchiata + if bIsMirrorMachiningOk and bIsMirrorSideOk and bIsMirrorOperationSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorOperationDistanceOk and bIsMirrorVectorOk then + -- calcolo asse di specchiatura + local dYMirrorAx + local b3Tab = EgtGetTableArea() + local ptOnMirrorAx = ( b3Operation:getCenter() + b3OperationMirror:getCenter()) / 2 + dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() + EgtSetCurrMachining( nOperIdMaster) + -- leggo note esistenti + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + -- aggiungo note per doppio + sUserNotes = EgtSetValInNotes( sUserNotes, 'DOUBLE', 2) + sUserNotes = EgtSetValInNotes( sUserNotes, 'MirrorAx', dYMirrorAx) + -- scrivo le note della lavorazione + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + -- cancello l'operazione specchiata + EgtRemoveOperation( nOperIdMirror) + break + end + nOperIdMirror = EgtGetNextOperation( nOperIdMirror) + end + end + nOperIdMaster = EgtGetNextOperation( nOperIdMaster) + end +end + ------------------------------------------------------------------------------------------------------------- function WallExec.ProcessFeatures() -- errori e stato @@ -962,7 +1037,7 @@ function WallExec.ProcessFeatures() local ProcId = vProcToDisable[i] if nOperationProcId == ProcId then nOperId = EgtGetNextOperation( nOperId) - EgtRemoveOperation(nCurrentOperId) + EgtRemoveOperation( nCurrentOperId) break end end @@ -971,15 +1046,7 @@ function WallExec.ProcessFeatures() end end --- -- verifico le fresature da specchiare --- local nClId = EgtGetFirstNameInGroup( nOperId, 'CL') --- local nPathId = EgtGetFirstInGroup( nClId or GDB_ID.NULL) --- local vtTool = EgtGetInfo( nPathId, 'EXTR', 'v') --- local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') --- local ptMax = EgtGetInfo( nClId, 'MMAX', 'p') --- local b3Operation = BBox3d( ptMin, ptMax) --- local sMachining = EgtGetMachiningParam( MCH_MP.NAME, 's') - + SetMirroredOperations() -- se macchina pareti if not WD.BEAM_MACHINE then From fa276949a26f779f9554d2fdd28e8031a86bbed0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 4 Sep 2023 17:56:07 +0200 Subject: [PATCH 25/43] - in WallExec completata ricerca e esecuzione di fresature in doppio da percorso specchiato - in WMachiningLib resa globale la funzione IsToolDoubleOk - piccole correzioni --- LuaLibs/WMachiningLib.lua | 12 ++- LuaLibs/WProcessFreeContour.lua | 11 +++ LuaLibs/WallExec.lua | 149 +++++++++++++++++++++++++++----- 3 files changed, 147 insertions(+), 25 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index c042091..b1892e2 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -187,8 +187,8 @@ function WMachiningLib.FindSurfacing( sType) end end --- incapsulo EgtAddMachining e trascrivo alcune informazioni utili nelle note dell'operazione --------------------------------------------------------------------- +-- incapsulo EgtAddMachining e trascrivo alcune informazioni utili nelle note dell'operazione function WMachiningLib.AddMachining( Proc, sName, sMachining) local nMchId, sFinalName = EgtAddMachining( sName, sMachining) if type(Proc) == 'table' then @@ -200,7 +200,8 @@ function WMachiningLib.AddMachining( Proc, sName, sMachining) end --------------------------------------------------------------------- -local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) +-- verifica se utensile sToolMasterName e gemello sToolDoubleName sono compatibili con la specchiatura +function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) local bIsToolDoubleOk = false -- dimensioni utensile master EgtTdbSetCurrTool( sToolMasterName) @@ -211,6 +212,7 @@ local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0 local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) + local bIsPrimaryHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) == 'H1' -- dimensioni utensile double EgtTdbSetCurrTool( sToolDoubleName) local bIsBladeDouble = ( EgtTdbGetCurrToolParam( MCH_TP.TYPE) & MCH_TF.SAWBLADE ~= 0) or false @@ -221,7 +223,8 @@ local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) -- controllo che siano uguali - bIsToolDoubleOk = ( bIsBlade == bIsBladeDouble) and + bIsToolDoubleOk = bIsPrimaryHead and + ( bIsBlade == bIsBladeDouble) and ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and @@ -233,6 +236,7 @@ local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) end --------------------------------------------------------------------- +-- verifica se la lavorazione sMachining è adatta alla specchiatura function WMachiningLib.IsMachiningOkForDouble( sMachining) local bDoubleOk = false if sMachining and EgtMdbSetCurrMachining( sMachining) then @@ -242,7 +246,7 @@ function WMachiningLib.IsMachiningOkForDouble( sMachining) -- cerco eventuale utensile in doppio local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then - bDoubleOk = IsToolDoubleOk( sToolMasterName, sToolDoubleName) + bDoubleOk = WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) end end end diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index b3be5cc..c6af9b3 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1315,6 +1315,8 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd nSCC = EgtIf( abs( vFace[i].Norm:getX()) > abs( vFace[i].Norm:getY()), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_YP) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- scrivo nell'operazione il vettore normale alla superfice che servirà per il doppio + EgtSetInfo( nMchId or GDB_ID.NULL, 'NORM_SUM', vFace[i].Norm) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -1512,6 +1514,13 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd -- posizione braccio porta testa EgtSetMachiningParam( MCH_MP.SCC, MCH_SCC.ADIR_XP) end + --scrivo nell'operazione il vettore somma delle normali alle superfici che servirà per il doppio + local vtNSum = Vector3d( 0, 0, 0) + for iGeom = 1, #vGeom do + local nFace = vGeom[iGeom][2] + vtNSum = vtNSum + Proc.Face[ nFace + 1].VtN + end + EgtSetInfo( nMchId or GDB_ID.NULL, 'NORM_SUM', vtNSum) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() @@ -1574,6 +1583,8 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd nSCC = EgtIf( abs( vFace[i].Norm:getX()) > abs( vFace[i].Norm:getY()), MCH_SCC.ADIR_XP, MCH_SCC.ADIR_YP) end EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- scrivo nell'operazione il vettore normale alla superfice che servirà per il doppio + EgtSetInfo( nMchId or GDB_ID.NULL, 'NORM_SUM', vFace[i].Norm) -- eseguo if not EgtApplyMachining( true, false) then local _, sErr = EgtGetLastMachMgrError() diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 3e45b29..81360a3 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -652,11 +652,14 @@ end -- funzione per l'ordinamento delle features in doppio da accoppiare -- ordinate prima in base alla X e poi alla Y local function SortFeaturesForMirror( Proc1, Proc2) + -- tolleranza di ricerca local TOL = EgtIf( Proc1.TopologyLongName == 'DRILLING', WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1 , WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) + -- recupero i centri dei box lungo X e Y local Proc1X = Proc1.Box:getCenter():getX() local Proc1Y = Proc1.Box:getCenter():getY() local Proc2X = Proc2.Box:getCenter():getX() local Proc2Y = Proc2.Box:getCenter():getY() + -- confronto per ordinamento if Proc1X < Proc2X - TOL then return true elseif abs( Proc1X - Proc2X) < TOL then @@ -666,12 +669,43 @@ local function SortFeaturesForMirror( Proc1, Proc2) end end +------------------------------------------------------------------------------------------------------------- +-- funzione per l'ordinamento delle operazioni in doppio da accoppiare +-- ordinate prima in base alla X e poi alla Y +local function SortOperationsForMirror( nOper1, nOper2) + -- tolleranza di ricerca + local TOL = 0.1 + -- recupero il box della prima operazione + local nClId1 = EgtGetFirstNameInGroup( nOper1, 'CL') + local ptMin1 = EgtGetInfo( nClId1, 'MMIN', 'p') + local ptMax1 = EgtGetInfo( nClId1, 'MMAX', 'p') + local b3Oper1 = BBox3d( ptMin1, ptMax1) + -- recupero il box delle seconda operazione + local nClId2 = EgtGetFirstNameInGroup( nOper2, 'CL') + local ptMin2 = EgtGetInfo( nClId2, 'MMIN', 'p') + local ptMax2 = EgtGetInfo( nClId2, 'MMAX', 'p') + local b3Oper2 = BBox3d( ptMin2, ptMax2) + -- recupero i centri dei box lungo X e Y + local nOper1X = b3Oper1:getCenter():getX() + local nOper1Y = b3Oper1:getCenter():getY() + local nOper2X = b3Oper2:getCenter():getX() + local nOper2Y = b3Oper2:getCenter():getY() + -- confronto per ordinamento + if nOper1X < nOper2X - TOL then + return true + elseif abs( nOper1X - nOper2X) < TOL then + if nOper1Y < nOper2Y - TOL then + return true + end + end +end + ------------------------------------------------------------------------------------------------------------- -- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri local function SetMirroredFeatures( vProc, b3Raw) - -- interasse minimo local dMinimumDistanceMirroredFeatures = 780 + -- inizializzazione array tasche e forature local vPockets = {} local vDrillings = {} @@ -715,6 +749,7 @@ local function SetMirroredFeatures( vProc, b3Raw) local Proc = vPockets[nCurrentPocket] if Proc.Flg ~= 0 then local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + -- cerco evenutale specchiata local nCurrentMirrorPocket = nCurrentPocket + 1 while nCurrentMirrorPocket <= #vPockets do local ProcMirror = vPockets[nCurrentMirrorPocket] @@ -794,7 +829,8 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.MirrorAx = dYMirrorAx -- Offset Z tra le feature Proc.MirrorDeltaZ = dDeltaZ - -- rimuovo dalla lista le groove già assegnate + + -- rimuovo dalla lista le pocket già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vPockets, nCurrentPocket) -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorPocket @@ -814,8 +850,9 @@ local function SetMirroredFeatures( vProc, b3Raw) while nCurrentDrilling <= #vDrillings do local Proc = vDrillings[nCurrentDrilling] if Proc.Flg ~= 0 then - local nCurrentMirrorDrilling = nCurrentDrilling + 1 local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD) + -- cerco evenutale specchiata + local nCurrentMirrorDrilling = nCurrentDrilling + 1 while nCurrentMirrorDrilling <= #vDrillings do local ProcMirror = vDrillings[nCurrentMirrorDrilling] local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD) @@ -838,14 +875,14 @@ local function SetMirroredFeatures( vProc, b3Raw) local b3Tab = EgtGetTableArea() local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2 dYMirrorAx = ptOnMirrorAx:getY() - b3Tab:getMin():getY() - -- scrivo i parametri nella lavorazione -- 2: specchiatura in Y Proc.Double = 2 Proc.Mirror = ProcMirror -- posizione Y dell'asse di specchiatura Proc.MirrorAx = dYMirrorAx - -- rimuovo dalla lista le groove già assegnate + + -- rimuovo dalla lista le forature già assegnate local ProcMirrorOldId = ProcMirror.Id table.remove( vDrillings, nCurrentDrilling) -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorDrilling @@ -866,34 +903,83 @@ end local function SetMirroredOperations() -- interasse minimo local dMinimumDistanceMirroredOperations = 780 - local nOperIdMaster = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) - while nOperIdMaster do + -- inzializzazione array + local vMillings = {} + + -- raccolgo le fresature non già fatte in doppio + local nOperId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + while nOperId do + EgtSetCurrMachining( nOperId) + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + local bIsDouble = ( EgtGetValInNotes( sUserNotes, 'DOUBLE', 'i') or 0) > 0 + if not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then + table.insert( vMillings, nOperId) + end + nOperId = EgtGetNextOperation( nOperId) + end + + -- ordinamento delle operazioni raccolte secondo X e poi Y crescente + table.sort( vMillings, SortOperationsForMirror) + + -- accoppio le fresature + local nCurrentMilling = 1 + while nCurrentMilling <= #vMillings do + local nOperIdMaster = vMillings[nCurrentMilling] EgtSetCurrMachining( nOperIdMaster) + local sMachining = EgtGetMachiningParam( MCH_MP.NAME, 's') local nClId = EgtGetFirstNameInGroup( nOperIdMaster, 'CL') local nPathId = EgtGetFirstInGroup( nClId or GDB_ID.NULL) - -- vettore direzione utensile lavorazione master + -- vettore direzione utensile e somma normali facce per lavorazione master local vtTool = EgtGetInfo( nPathId, 'EXTR', 'v') + local vtNormSum = EgtGetInfo( nOperIdMaster, 'NORM_SUM', 'v') local ptMin = EgtGetInfo( nClId, 'MMIN', 'p') local ptMax = EgtGetInfo( nClId, 'MMAX', 'p') -- box percorso lavorazione master local b3Operation = BBox3d( ptMin, ptMax) - local sMachining = EgtGetMachiningParam( MCH_MP.NAME, 's') -- lavorazione master adatta alla specchiatura - local bIsMachiningOk = ( EgtGetMachiningParam( MCH_MP.TYPE) == MCH_OY.MILLING) and EgtGetOperationMode( nOperIdMaster) and WM.IsMachiningOkForDouble( sMachining) - local nOperIdMirror = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + local bIsMachiningOk = EgtGetOperationMode( nOperIdMaster) and WM.IsMachiningOkForDouble( sMachining) if bIsMachiningOk then - while nOperIdMirror do + -- recupero la distanza tra centro di rotazione e punta dell'utensile per aumentare o ridurre l'interasse minimo + local dTipToPivot, dTipToPivotDouble = 999, 999 + local dToolMasterTotLength, dToolMasterTotLengthDouble = 999, 999 + local sToolMasterName = '' + if EgtMdbSetCurrMachining( sMachining) then + -- recupero l'utensile della lavorazione e il suo doppio + sToolMasterName = EgtMdbGetCurrMachiningParam( MCH_MP.TOOL) + if EgtTdbSetCurrTool( sToolMasterName or '') then + dToolMasterTotLength = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) or dToolMasterTotLength + local sToolDoubleName = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'DOUBLE', 's') + if sToolDoubleName and EgtTdbSetCurrTool( sToolDoubleName) then + dToolMasterTotLengthDouble = EgtTdbGetCurrToolParam( MCH_TP.TOTLEN) or dToolMasterTotLengthDouble + end + end + end + if WD.HEAD_PIVOT_MAIN and WD.HEAD_PIVOT_SECONDARY then + dTipToPivot = dToolMasterTotLength + WD.HEAD_PIVOT_MAIN + dTipToPivotDouble = dToolMasterTotLengthDouble + WD.HEAD_PIVOT_SECONDARY + else + local sOut = 'Error : HEAD_PIVOT_MAIN or HEAD_PIVOT_SECONDARY missing in WallData' + return false, sOut + end + -- cerco eventuale specchiata + local nCurrentMirrorMilling = nCurrentMilling + 1 + while nCurrentMirrorMilling <= #vMillings do + local nOperIdMirror = vMillings[nCurrentMirrorMilling] EgtSetCurrMachining( nOperIdMirror) local nClIdMirror = EgtGetFirstNameInGroup( nOperIdMirror, 'CL') local nPathIdMirror = EgtGetFirstInGroup( nClIdMirror or GDB_ID.NULL) - -- vettore direzione utensile lavorazione mirror + -- vettore direzione utensile e somma normali facce per lavorazione mirror local vtToolMirror = EgtGetInfo( nPathIdMirror, 'EXTR', 'v') + local vtNormSumMirror = EgtGetInfo( nOperIdMirror, 'NORM_SUM', 'v') local ptMinMirror = EgtGetInfo( nClIdMirror, 'MMIN', 'p') local ptMaxMirror = EgtGetInfo( nClIdMirror, 'MMAX', 'p') -- box percorso lavorazione mirror local b3OperationMirror = BBox3d( ptMinMirror, ptMaxMirror) + -- utensile originale lavorazione specchiata + local sOriginalMirrorToolName = EgtGetMachiningParam( MCH_MP.TOOL) + local bIsOriginalMirrorToolSameSize = WM.IsToolDoubleOk( sToolMasterName, sOriginalMirrorToolName) -- lavorazione mirror adatta alla specchiatura - local bIsMirrorMachiningOk = ( EgtGetMachiningParam( MCH_MP.TYPE) == MCH_OY.MILLING) and EgtGetOperationMode( nOperIdMirror) and nOperIdMaster ~= nOperIdMirror + local bIsMirrorMachiningOk = EgtGetOperationMode( nOperIdMirror) and nOperIdMaster ~= nOperIdMirror -- lavorazione master più a sinistra local bIsMirrorSideOk = ( b3OperationMirror:getCenter():getY() - b3Operation:getCenter():getY()) > ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box delle stesse dimensioni @@ -906,13 +992,27 @@ local function SetMirroredOperations() -- box che non si intersecano local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Operation, b3OperationMirror) -- distanza minima tra le feature + local dTipToPivotProjectionOnY = dTipToPivot * vtTool:getY() + local dTipToPivotProjectionOnYDouble = dTipToPivotDouble * vtToolMirror:getY() local dYMinDistance = max( b3Operation:getMin():getY(), b3OperationMirror:getMin():getY()) - min( b3Operation:getMax():getY(), b3OperationMirror:getMax():getY()) - local bIsMirrorOperationDistanceOk = dYMinDistance > dMinimumDistanceMirroredOperations + 10 * GEO.EPS_SMALL - -- vettori utensile specchiati - vtTool:mirror( Y_AX()) - local bIsMirrorVectorOk = AreSameVectorApprox( vtTool, vtToolMirror) + local bIsMirrorOperationDistanceOk = dYMinDistance > dMinimumDistanceMirroredOperations + dTipToPivotProjectionOnY - dTipToPivotProjectionOnYDouble + 10 * GEO.EPS_SMALL + -- vettori utensile e somma normali facce specchiati + local vtToolMirrored = Vector3d( vtTool) + vtToolMirrored:mirror( Y_AX()) + local bIsMirrorVectorOk = false + if AreSameVectorApprox( vtToolMirrored, vtToolMirror) then + if AreSameVectorApprox(vtTool, vtToolMirror) then + if vtNormSum and vtNormSumMirror then + local vtNormSumMirrored = Vector3d( vtNormSum) + vtNormSumMirrored:mirror( Y_AX()) + bIsMirrorVectorOk = AreSameVectorApprox( vtNormSumMirrored, vtNormSumMirror) + end + else + bIsMirrorVectorOk = true + end + end -- se condizioni corrette, scrivo le note e cancello la specchiata - if bIsMirrorMachiningOk and bIsMirrorSideOk and bIsMirrorOperationSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorOperationDistanceOk and bIsMirrorVectorOk then + if bIsOriginalMirrorToolSameSize and bIsMirrorMachiningOk and bIsMirrorSideOk and bIsMirrorOperationSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorOperationDistanceOk and bIsMirrorVectorOk then -- calcolo asse di specchiatura local dYMirrorAx local b3Tab = EgtGetTableArea() @@ -928,12 +1028,19 @@ local function SetMirroredOperations() EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- cancello l'operazione specchiata EgtRemoveOperation( nOperIdMirror) + -- rimuovo dalla lista le fresature già assegnate + local nCurrentMirrorMillingOldId = nCurrentMirrorMilling + table.remove( vMillings, nCurrentMilling) + -- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorPocket + if nCurrentMirrorMilling > #vMillings or ( vMillings[nCurrentMirrorMilling] ~= nCurrentMirrorMillingOldId) then nCurrentMirrorMilling = nCurrentMirrorMilling - 1 end + table.remove( vMillings, nCurrentMirrorMilling) + nCurrentMilling = 0 break end - nOperIdMirror = EgtGetNextOperation( nOperIdMirror) + nCurrentMirrorMilling = nCurrentMirrorMilling + 1 end end - nOperIdMaster = EgtGetNextOperation( nOperIdMaster) + nCurrentMilling = nCurrentMilling + 1 end end From 61e5ce63593f211b69495ea8ecf1507b5fae344c Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 5 Sep 2023 16:14:05 +0200 Subject: [PATCH 26/43] - aggiunta costante if WD.DOUBLE_HEAD_MILLCORNER per attivazione puliture in doppio --- LuaLibs/WallExec.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 81360a3..6fd50ce 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -907,15 +907,17 @@ local function SetMirroredOperations() local vMillings = {} -- raccolgo le fresature non già fatte in doppio - local nOperId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) - while nOperId do - EgtSetCurrMachining( nOperId) - local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) - local bIsDouble = ( EgtGetValInNotes( sUserNotes, 'DOUBLE', 'i') or 0) > 0 - if not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then - table.insert( vMillings, nOperId) + if WD.DOUBLE_HEAD_MILLCORNER then + local nOperId = EgtGetNextOperation( EgtGetPhaseDisposition( 1)) + while nOperId do + EgtSetCurrMachining( nOperId) + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + local bIsDouble = ( EgtGetValInNotes( sUserNotes, 'DOUBLE', 'i') or 0) > 0 + if not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then + table.insert( vMillings, nOperId) + end + nOperId = EgtGetNextOperation( nOperId) end - nOperId = EgtGetNextOperation( nOperId) end -- ordinamento delle operazioni raccolte secondo X e poi Y crescente From 6a2a87b91f2c23a415a4b400fa962e03d3efcfc8 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 7 Sep 2023 12:23:27 +0200 Subject: [PATCH 27/43] - la Topology tunnel chiuso diventa pocket - piccole correzioni alla raccolta features in doppio in WallExec - correzione in LApJoint per evitare di lavorare groove completamente affondate nel grezzo --- LuaLibs/WFeatureTopology.lua | 2 +- LuaLibs/WProcessLapJoint.lua | 2 +- LuaLibs/WallExec.lua | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/LuaLibs/WFeatureTopology.lua b/LuaLibs/WFeatureTopology.lua index ec07b2f..191c868 100644 --- a/LuaLibs/WFeatureTopology.lua +++ b/LuaLibs/WFeatureTopology.lua @@ -208,7 +208,7 @@ function WFeatureTopology.Classify( Proc) sFamily = 'Tunnel' bIsThrough = true elseif Proc.Fct == 5 and bAllAnglesConcave and #vFacesWithFourAdj == 1 then - sFamily = 'Tunnel' + sFamily = 'Pocket' bIsThrough = false end local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 5fa38d1..39467ca 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -1510,7 +1510,7 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d end end -- se profondità ribasso è maggiore della capacità di sottosquadro dell'utensile - if ( not bEnablePreMill and bMachFromDn) and ( dElev > 0.5 * ( dMillDiam - dMillDiamTh) - 10 * GEO.EPS_SMALL) then + if ( not bEnablePreMill and ( bMachFromDn or Proc.Fct > 2)) and ( dElev > 0.5 * ( dMillDiam - dMillDiamTh) - 10 * GEO.EPS_SMALL) then local sErr = 'Error : Side Elevation (' .. dElev .. ') bigger than max tool side depth (' .. ( 0.5 * ( dMillDiam - dMillDiamTh)) ..')' EgtOutLog( sErr) return false, sErr diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 6fd50ce..47bd8d1 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -686,15 +686,15 @@ local function SortOperationsForMirror( nOper1, nOper2) local ptMax2 = EgtGetInfo( nClId2, 'MMAX', 'p') local b3Oper2 = BBox3d( ptMin2, ptMax2) -- recupero i centri dei box lungo X e Y - local nOper1X = b3Oper1:getCenter():getX() - local nOper1Y = b3Oper1:getCenter():getY() - local nOper2X = b3Oper2:getCenter():getX() - local nOper2Y = b3Oper2:getCenter():getY() + local dOper1X = b3Oper1:getCenter():getX() + local dOper1Y = b3Oper1:getCenter():getY() + local dOper2X = b3Oper2:getCenter():getX() + local dOper2Y = b3Oper2:getCenter():getY() -- confronto per ordinamento - if nOper1X < nOper2X - TOL then + if dOper1X < dOper2X - TOL then return true - elseif abs( nOper1X - nOper2X) < TOL then - if nOper1Y < nOper2Y - TOL then + elseif abs( dOper1X - dOper2X) < TOL then + if dOper1Y < dOper2Y - TOL then return true end end @@ -720,7 +720,7 @@ local function SetMirroredFeatures( vProc, b3Raw) ( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and ( not Proc.AffectedFaces.Bottom and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right)) or ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3') or ( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4') or - ( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and not Proc.AffectedFaces.Bottom) + ( Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' and not Proc.AffectedFaces.Bottom) ) then table.insert( vPockets, Proc) -- raccolgo i fori verticali e aperti verso Z+ @@ -765,7 +765,7 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or - Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' + Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' ) -- se di fianco, determino se è l'ultima parte prima della fine del grezzo local bIsFeatureOnEdge, bIsMirrorFeatureOnEdge = false, false @@ -794,7 +794,7 @@ local function SetMirroredFeatures( vProc, b3Raw) Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or - Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top + Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top -- box delle stesse dimensioni local bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and @@ -913,7 +913,7 @@ local function SetMirroredOperations() EgtSetCurrMachining( nOperId) local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) local bIsDouble = ( EgtGetValInNotes( sUserNotes, 'DOUBLE', 'i') or 0) > 0 - if not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then + if EgtGetOperationMode( nOperId) and not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then table.insert( vMillings, nOperId) end nOperId = EgtGetNextOperation( nOperId) @@ -939,7 +939,7 @@ local function SetMirroredOperations() -- box percorso lavorazione master local b3Operation = BBox3d( ptMin, ptMax) -- lavorazione master adatta alla specchiatura - local bIsMachiningOk = EgtGetOperationMode( nOperIdMaster) and WM.IsMachiningOkForDouble( sMachining) + local bIsMachiningOk = WM.IsMachiningOkForDouble( sMachining) if bIsMachiningOk then -- recupero la distanza tra centro di rotazione e punta dell'utensile per aumentare o ridurre l'interasse minimo local dTipToPivot, dTipToPivotDouble = 999, 999 @@ -981,7 +981,7 @@ local function SetMirroredOperations() local sOriginalMirrorToolName = EgtGetMachiningParam( MCH_MP.TOOL) local bIsOriginalMirrorToolSameSize = WM.IsToolDoubleOk( sToolMasterName, sOriginalMirrorToolName) -- lavorazione mirror adatta alla specchiatura - local bIsMirrorMachiningOk = EgtGetOperationMode( nOperIdMirror) and nOperIdMaster ~= nOperIdMirror + local bIsMirrorMachiningOk = nOperIdMaster ~= nOperIdMirror -- lavorazione master più a sinistra local bIsMirrorSideOk = ( b3OperationMirror:getCenter():getY() - b3Operation:getCenter():getY()) > ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) -- box delle stesse dimensioni From b2fdd271303c4005f5eab6a1290ae65927e80d45 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 7 Sep 2023 17:03:12 +0200 Subject: [PATCH 28/43] in WallExec -> SetMirroredOperations ora si controlla che la lavorazione non sia vuota prima di aggiungerla alla lista delle plausibili per doppio --- LuaLibs/WallExec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 47bd8d1..a74fbc0 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -913,7 +913,7 @@ local function SetMirroredOperations() EgtSetCurrMachining( nOperId) local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) local bIsDouble = ( EgtGetValInNotes( sUserNotes, 'DOUBLE', 'i') or 0) > 0 - if EgtGetOperationMode( nOperId) and not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then + if EgtGetOperationMode( nOperId) and not EgtIsMachiningEmpty( nOperId) and not bIsDouble and EgtGetOperationType( nOperId) == MCH_OY.MILLING then table.insert( vMillings, nOperId) end nOperId = EgtGetNextOperation( nOperId) From 9f014c70f723dca7dfd117886ecdde4c18ea6ad9 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 11 Sep 2023 09:56:22 +0200 Subject: [PATCH 29/43] - lievi correzioni --- LuaLibs/WProcessLapJoint.lua | 8 +++----- LuaLibs/WallExec.lua | 5 ----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 39467ca..0480f72 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -2222,11 +2222,9 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) end end -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa - if WD.AVOID_DAMAGING_OTHER_PARTS then - if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or - Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then - bForceClosedPocket = true - end + if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or + Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then + bForceClosedPocket = true end -- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa else diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index a74fbc0..388bd42 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -192,24 +192,19 @@ function WallExec.CollectFeatures( PartId, b3Raw) Proc.TaskId = nTaskId Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) Proc.IsOutline = ( Proc.Prc == 251 or Proc.Prc == 252) - if b3Raw then -- recupero l'elenco delle facce della parte interessate dalla feature Proc.AffectedFaces = WL.GetProcessAffectedFaces( Proc) - -- recupero le distanze tra la feature e le altre parti più vicine Proc.DistanceToNearestParts = WL.GetProcessDistanceToNearestParts( Proc) - -- recupero le distanze tra la feature e il grezzo Proc.DistanceToRawPart = WL.GetProcessDistanceToRawPart( Proc, b3Raw) - -- recupero informazioni sulle facce della feature Proc.Face = {} for i = 1, Proc.Fct do Proc.Face[i] = { Id = i - 1, VtN = EgtSurfTmFacetNormVersor( Proc.Id, i - 1, GDB_ID.ROOT ), Elevation = WL.GetFaceElevation( Proc.Id, i - 1, PartId)} end end - if Proc.Box and not Proc.Box:isEmpty() then table.insert( vProc, Proc) -- se foro From 79e97c9e1f69faacb8bd478c897a4ea72bc41e5d Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 28 Sep 2023 09:26:38 +0200 Subject: [PATCH 30/43] - migliorata WallLib -> Is3EdgesApprox --- LuaLibs/WallLib.lua | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index ac1b5b7..491ba3a 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -377,25 +377,29 @@ end --------------------------------------------------------------------- -- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce -function WallLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId) +function Is3EdgesApprox( Proc, nFacet, nAddGrpId) nAddGrpId = nAddGrpId or WallLib.GetAddGroup( Proc.PartId) - local bResult = false - local nContourId = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) + -- recupero il contorno della faccia + local nContourId, nContourCnt = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) + if not nContourId then return false end EgtMergeCurvesInCurveCompo( nContourId) - -- recupero il numero effettivo di lati + -- recupero il numero di lati del contorno local _, nEntityCount = EgtCurveDomain( nContourId) + if not nEntityCount then return false end + -- se sono già tre, ho finito + if nEntityCount == 3 then return true end + -- rimuovo i lati molto corti dal conteggio totale local nEdges = nEntityCount - if nContourId then - if nEntityCount and nEntityCount == 3 then - bResult = true - -- rimuovo i lati molto corti dal conteggio totale - elseif nEntityCount then - for i = 1, nEntityCount do - local dLength = EgtCurveCompoLength( nContourId, i - 1) - if dLength < 15 then nEdges = nEdges - 1 end - end - end - if nEdges == 3 then bResult = true end + for i = 1, nEntityCount do + local dLength = EgtCurveCompoLength( nContourId, i - 1) + if dLength < 15 then nEdges = nEdges - 1 end + end + -- verifico il numero significativo di lati + local bResult = ( nEdges == 3) + -- cancello tutti i contorni appena creati + EgtErase( EgtTableFill( nContourId, nContourCnt)) + if bResult then + EgtOutLog( 'FreeContour : Face with ' .. tostring( nEntityCount) .. ' edges skipped (approx 3 edges)') end return bResult end From 47ec8939599f276f49d3c8988d97c691033ad352 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 28 Sep 2023 16:36:43 +0200 Subject: [PATCH 31/43] - piccole correzioni bug --- LuaLibs/WallExec.lua | 16 +++++++++------- LuaLibs/WallLib.lua | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 45d9331..55de73a 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -1135,14 +1135,16 @@ function WallExec.ProcessFeatures() while nOperId do EgtSetCurrMachining( nOperId) local nOperationProcIds = EgtGetMachiningGeometry() - local nOperationProcId = nOperationProcIds[1][1] local nCurrentOperId = nOperId - for i = 1, #vProcToDisable do - local ProcId = vProcToDisable[i] - if nOperationProcId == ProcId then - nOperId = EgtGetNextOperation( nOperId) - EgtRemoveOperation( nCurrentOperId) - break + if #nOperationProcIds > 0 then + local nOperationProcId = nOperationProcIds[1][1] + for i = 1, #vProcToDisable do + local ProcId = vProcToDisable[i] + if nOperationProcId == ProcId then + nOperId = EgtGetNextOperation( nOperId) + EgtRemoveOperation( nCurrentOperId) + break + end end end if nCurrentOperId == nOperId then diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index 491ba3a..c609ed5 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -377,7 +377,7 @@ end --------------------------------------------------------------------- -- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce -function Is3EdgesApprox( Proc, nFacet, nAddGrpId) +function WallLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId) nAddGrpId = nAddGrpId or WallLib.GetAddGroup( Proc.PartId) -- recupero il contorno della faccia local nContourId, nContourCnt = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) From 9edd6aec23c80aa7fe904b1174ae6132d462d149 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 19 Oct 2023 09:54:01 +0200 Subject: [PATCH 32/43] - nella ricerca lavorazione da usare controllo di utensile attivo sostituito con controllo utensile presente nel setup corrente --- LuaLibs/WMachiningLib.lua | 2 +- LuaLibs/WProcessDrill.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 17f756d..812dd73 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -232,7 +232,7 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and ( bTipFeed == bTipFeedDouble) and ( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and - EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + EgtFindToolInCurrSetup( sToolDoubleName) return bIsToolDoubleOk end diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index 690f664..a273ef1 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -170,7 +170,7 @@ local function IsToolDoubleOk( sToolMasterName, sToolDoubleName) -- controllo che siano uguali bIsToolDoubleOk = ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and - EgtTdbGetCurrToolParam( MCH_TP.ACTIVE) + EgtFindToolInCurrSetup( sToolDoubleName) return bIsToolDoubleOk end From 5340c6a92ceed3bd899ea4d49ada4b58d9e0bcad Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 19 Oct 2023 18:10:45 +0200 Subject: [PATCH 33/43] - update del compile per includere topology --- Compile.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Compile.bat b/Compile.bat index 504701d..10126dc 100644 --- a/Compile.bat +++ b/Compile.bat @@ -11,7 +11,7 @@ REM Compilazione 32 e 64 bit \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessDoubleCut.lua LuaLibs\WProcessDoubleCut.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessDrill.lua LuaLibs\WProcessDrill.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessDtMortise.lua LuaLibs\WProcessDtMortise.lua -REM \EgtProg\Dll32\luac54 -o bin\LuaLibs\WFeatureTopology.lua LuaLibs\WFeatureTopology.lua +\EgtProg\Dll32\luac54 -o bin\LuaLibs\WFeatureTopology.lua LuaLibs\WFeatureTopology.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessFreeContour.lua LuaLibs\WProcessFreeContour.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessLapJoint.lua LuaLibs\WProcessLapJoint.lua \EgtProg\Dll32\luac54 -o bin\LuaLibs\WProcessMark.lua LuaLibs\WProcessMark.lua From f29816c693dfb5787b750c8d55ac6fae2515db58 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 30 Oct 2023 18:22:04 +0100 Subject: [PATCH 34/43] - In LapJoint -> VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. - In MachiningLib -> FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. - In WallExec -> SetMirroredFeatures permesso il doppio per groove con specchiata non sul fianco se settate per essere lavorate come pocket. --- LuaLibs/WMachiningLib.lua | 13 ++++++++----- LuaLibs/WProcessLapJoint.lua | 5 +++-- LuaLibs/WallExec.lua | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 812dd73..acce115 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -6,6 +6,7 @@ -- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura di alcune info alle lavorazioni. -- 2023/07/13 In FindMilling, FindPocketing aggiunta la possibilità di limitare la ricerca lavorazioni alla sola testa specificata. -- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. +-- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. -- Tabella per definizione modulo local WMachiningLib = {} @@ -103,7 +104,7 @@ function WMachiningLib.FindNailing( nType) end --------------------------------------------------------------------- -function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead) +function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, bExcludeNoTipFeed) for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then @@ -112,11 +113,13 @@ function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead) local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), EgtTdbGetCurrToolMaxDepth()) local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + local bHasTipFeed = ( EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0) if nMchType == MCH_MY.POCKETING and ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) and - ( not sHead or sHead == sMyHead) then + ( not sHead or sHead == sMyHead) and + ( not bExcludeNoTipFeed or bHasTipFeed) then return Pocketing.Name, dTDiam, dTMaxDepth end end @@ -211,7 +214,7 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) local dTMaxDepth = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMat, EgtTdbGetCurrToolMaxDepth()) local dTDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTDiamTh = EgtTdbGetCurrToolThDiam() or 0 - local bTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local bHasTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0 local dTMaxDepthOnSide = EgtIf( bIsBlade, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiam - dTDiamTh))) local bIsPrimaryHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) == 'H1' -- dimensioni utensile double @@ -221,7 +224,7 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) local dTMaxDepthDouble = EgtIf( WD.MILL_MAX_DEPTH_AS_MAT, dTMaxMatDouble, EgtTdbGetCurrToolMaxDepth()) local dTDiamDouble = EgtTdbGetCurrToolParam( MCH_TP.DIAM) local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0 - local bTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) > 0 + local bHasTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0 local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) -- controllo che siano uguali bIsToolDoubleOk = bIsPrimaryHead and @@ -230,7 +233,7 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and - ( bTipFeed == bTipFeedDouble) and + ( bHasTipFeed == bHasTipFeedDouble) and ( abs( dTMaxDepthOnSide - dTMaxDepthOnSideDouble) < GEO.EPS_SMALL) and EgtFindToolInCurrSetup( sToolDoubleName) return bIsToolDoubleOk diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index a8cd712..748fee0 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -30,6 +30,7 @@ -- 2023/09/21 Modifica controllo lavorabilità con tre facce tipo tunnel ma non ortogonali tra loro. -- 2023/09/21 In MakeByMill modificato SCC per correggere caso con lama su testa fresa. -- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata. +-- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. -- Tabella per definizione modulo local WPL = {} @@ -2214,7 +2215,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup @@ -2249,7 +2250,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1') + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index bfb369c..fecc960 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -5,6 +5,7 @@ -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. +-- 2023/10/30 In SetMirroredFeatures permesso il doppio per groove con specchiata non sul fianco se settate per essere lavorate come pocket. -- Tabella per definizione modulo local WallExec = {} @@ -796,7 +797,7 @@ local function SetMirroredFeatures( vProc, b3Raw) end end -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo - local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge ) or + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and ( bIsMirrorFeatureOnEdge or nDoubleType == 1)) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or From 31172238d8b438e33305c7478e7bd8d1b95cd20d Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 31 Oct 2023 16:41:10 +0100 Subject: [PATCH 35/43] - In LpJoint -> IsToolDoubleOk permessa una lunghezza inferiore di 5.5mm dell'utensile secondario rispetto al principale --- LuaLibs/WMachiningLib.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index acce115..d41caad 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -7,6 +7,7 @@ -- 2023/07/13 In FindMilling, FindPocketing aggiunta la possibilità di limitare la ricerca lavorazioni alla sola testa specificata. -- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. -- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. +-- 2023/10/31 In IsToolDoubleOk permessa una lunghezza inferiore di 5.5mm dell'utensile secondario rispetto al principale. -- Tabella per definizione modulo local WMachiningLib = {} @@ -226,11 +227,11 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) local dTDiamThDouble = EgtTdbGetCurrToolThDiam() or 0 local bHasTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0 local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) - -- controllo che siano uguali + -- controllo che siano uguali ( permetto una leggera differenza di lunghezza) bIsToolDoubleOk = bIsPrimaryHead and ( bIsBlade == bIsBladeDouble) and ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and - ( dTMaxDepthDouble > dTMaxDepth - 100 * GEO.EPS_SMALL) and + ( dTMaxDepthDouble > dTMaxDepth - 5.5) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and ( bHasTipFeed == bHasTipFeedDouble) and From fea5cfd8ed452a693d1d0dc9231fe1f262d7366f Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 31 Oct 2023 17:25:20 +0100 Subject: [PATCH 36/43] - In LapJoint -> VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa. --- LuaLibs/WMachiningLib.lua | 5 +++-- LuaLibs/WProcessLapJoint.lua | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index d41caad..e2714d4 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -7,7 +7,7 @@ -- 2023/07/13 In FindMilling, FindPocketing aggiunta la possibilità di limitare la ricerca lavorazioni alla sola testa specificata. -- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. -- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. --- 2023/10/31 In IsToolDoubleOk permessa una lunghezza inferiore di 5.5mm dell'utensile secondario rispetto al principale. +-- 2023/10/31 In IsToolDoubleOk permessa una lunghezza lievemente inferiore dell'utensile secondario rispetto al principale. -- Tabella per definizione modulo local WMachiningLib = {} @@ -228,10 +228,11 @@ function WMachiningLib.IsToolDoubleOk( sToolMasterName, sToolDoubleName) local bHasTipFeedDouble = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0 local dTMaxDepthOnSideDouble = EgtIf( bIsBladeDouble, EgtTdbGetCurrToolParam( MCH_TP.MAXMAT), min( EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDEDEPTH', 'd') or 999, 0.5 * ( dTDiamDouble - dTDiamThDouble))) -- controllo che siano uguali ( permetto una leggera differenza di lunghezza) + local dMaxLengthDifference = 6.5 bIsToolDoubleOk = bIsPrimaryHead and ( bIsBlade == bIsBladeDouble) and ( dTMaxMatDouble > dTMaxMat - 100 * GEO.EPS_SMALL) and - ( dTMaxDepthDouble > dTMaxDepth - 5.5) and + ( dTMaxDepthDouble > dTMaxDepth - dMaxLengthDifference) and ( abs( dTDiam - dTDiamDouble) < 100 * GEO.EPS_SMALL) and ( abs( dTDiamTh - dTDiamThDouble) < 100 * GEO.EPS_SMALL) and ( bHasTipFeed == bHasTipFeedDouble) and diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 748fee0..224bea3 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -31,6 +31,7 @@ -- 2023/09/21 In MakeByMill modificato SCC per correggere caso con lama su testa fresa. -- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata. -- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. +-- 2023/10/31 In VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa. -- Tabella per definizione modulo local WPL = {} @@ -2198,13 +2199,14 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) end local bForceClosedPocket = false + local bExcludeNoTipFeed = Proc.Topology == 'Pocket' -- recupero la lavorazione local bUseDElevToFindPocketing = true - local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev) + local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) -- se tasca troppo profonda cerco senza elevazione e limiterò la profondità if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) end local dMillDiam = 20 local dMaxDepth = 0 @@ -2242,10 +2244,10 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) if bForceClosedPocket then dMaxDiameter = min( dH, dV) bUseDElevToFindPocketing = true - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) end -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then From f9bb10bf6ef405ff955defd5c41f6375f17928f2 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 31 Oct 2023 18:47:38 +0100 Subject: [PATCH 37/43] - in LapJoint -> FindPocketing le lavorazioni con attacco speciale (rampa molto lunga e step basso) ignorano il flag per escludere le frese che non lavorano di testa. --- LuaLibs/WMachiningLib.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index e2714d4..3701aba 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -8,6 +8,7 @@ -- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. -- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. -- 2023/10/31 In IsToolDoubleOk permessa una lunghezza lievemente inferiore dell'utensile secondario rispetto al principale. +-- 2023/10/31 In FindPocketing le lavorazioni con attacco speciale (rampa molto lunga e step basso) ignorano il flag per escludere le frese che non lavorano di testa. -- Tabella per definizione modulo local WMachiningLib = {} @@ -115,12 +116,15 @@ function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) local bHasTipFeed = ( EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0) + local bIsSpecialLeadIn = ( EgtMdbGetCurrMachiningParam( MCH_MP.LEADINTYPE) == MCH_POCK_LI.ZIGZAG or MCH_POCK_LI.HELIX) and + ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LITANG) or 0) > dTDiam - 10 * GEO.EPS_SMALL) and + ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LIELEV) or 999) <= 2) if nMchType == MCH_MY.POCKETING and ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and ( not nTool_ID or nTool_ID == 0 or nTool_ID == nMyTool_ID) and ( not sHead or sHead == sMyHead) and - ( not bExcludeNoTipFeed or bHasTipFeed) then + ( not bExcludeNoTipFeed or bHasTipFeed or bIsSpecialLeadIn) then return Pocketing.Name, dTDiam, dTMaxDepth end end From a84fb0608ff6f2ec3d9e67cfc7ea17aa7520f747 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Thu, 9 Nov 2023 18:17:17 +0100 Subject: [PATCH 38/43] - varie modifiche, principalmente a MachiningLib e LapJoint, che migliorano il funzionamento delle tasche, anche in doppio. --- LuaLibs/WMachiningLib.lua | 12 ++- LuaLibs/WProcessLapJoint.lua | 155 +++++++++++++++++++++-------------- LuaLibs/WallExec.lua | 3 +- LuaLibs/WallLib.lua | 2 +- 4 files changed, 104 insertions(+), 68 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 3701aba..1595e2c 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -9,6 +9,7 @@ -- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. -- 2023/10/31 In IsToolDoubleOk permessa una lunghezza lievemente inferiore dell'utensile secondario rispetto al principale. -- 2023/10/31 In FindPocketing le lavorazioni con attacco speciale (rampa molto lunga e step basso) ignorano il flag per escludere le frese che non lavorano di testa. +-- 2023/11/06 In FindPocketing aggiunto parametro dDistanceToNearestPart per ridurre il massimo diametro in caso di altro pezzo troppo vicino. -- Tabella per definizione modulo local WMachiningLib = {} @@ -106,7 +107,8 @@ function WMachiningLib.FindNailing( nType) end --------------------------------------------------------------------- -function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, bExcludeNoTipFeed) +function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, bExcludeNoTipFeed, dDistanceToNearestPart) + if not dMaxDiam then dMaxDiam = 999 end for i = 1, #Pocketings do local Pocketing = Pocketings[i] if Pocketing.On and Pocketing.Type == sType and SetCurrMachiningAndTool( Pocketing.Name) then @@ -116,9 +118,15 @@ function WMachiningLib.FindPocketing( sType, dMaxDiam, dDepth, nTool_ID, sHead, local nMyTool_ID = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'Tool_ID', 'i') local sMyHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) local bHasTipFeed = ( EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) ~= 0) + -- attacco con rampa molto lunga e step basso, utilizzabile anche con frese che non lavorano di testa local bIsSpecialLeadIn = ( EgtMdbGetCurrMachiningParam( MCH_MP.LEADINTYPE) == MCH_POCK_LI.ZIGZAG or MCH_POCK_LI.HELIX) and - ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LITANG) or 0) > dTDiam - 10 * GEO.EPS_SMALL) and + ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LITANG) or 0) > dTDiam - 1 - 10 * GEO.EPS_SMALL) and ( ( EgtMdbGetCurrMachiningParam( MCH_MP.LIELEV) or 999) <= 2) + local bIsSpiralOut = EgtMdbGetCurrMachiningParam( MCH_MP.SUBTYPE) == MCH_POCK_SUB.SPIRALOUT + -- se ho un altro pezzo troppo vicino riduco il diametro massimo utensile + if dDistanceToNearestPart then + dMaxDiam = min( dMaxDiam, EgtIf( bIsSpiralOut, dDistanceToNearestPart * 2 + 5, dDistanceToNearestPart + 5)) + end if nMchType == MCH_MY.POCKETING and ( not dMaxDiam or dTDiam < dMaxDiam + GEO.EPS_SMALL) and ( not dDepth or dTMaxDepth > dDepth - GEO.EPS_SMALL) and diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 224bea3..fa463d4 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -32,7 +32,10 @@ -- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata. -- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. -- 2023/10/31 In VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa. - +-- 2023/11/06 In VerifyPocket controllo massimo diametro in base a distanza pezzo più vicino demandato a FindPocketing. +-- 2023/11/07 In MakeByPocketing, se tasca che guarda davanti, aggiunta possibilità di attaccare fuori dal grezzo fino ad uno spessore di 75 mm. +-- In MakeByPocketing calcolo del massimo diametro utensile spostato in VerifyPocketing. +-- In MakeByPocketing il doppio viene ora disattivato se una tasca deve essere forzata chiusa e l'altra no. -- Tabella per definizione modulo local WPL = {} @@ -1290,7 +1293,7 @@ local function IsMachiningDamagingOtherParts( Proc, dMillDiameter, nRawId) local ptMin = b3ProcExtended:getMin() local ptMax = b3ProcExtended:getMax() -- estensione aggiunta ai box - local dBoxExtensionLength = dMillDiameter / 2 + 10 + local dBoxExtensionLength = dMillDiameter / 2 + 5 -- check box verso X- if Proc.AffectedFaces.Left then local vtMove = Vector3d( -dBoxExtensionLength, 0, 0) @@ -2183,30 +2186,76 @@ end --------------------------------------------------------------------- -- trova la migliore lavorazione tasca in base a diametro utensile, elevazione, doppio e eventuale interferenza di parti vicine -- se necessario forza la tasca a chiusa -local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) - local dStartDiameter = dMaxDiameter - if Proc.AffectedFaces.Front then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Front) - end - if Proc.AffectedFaces.Back then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Back) - end - if Proc.AffectedFaces.Left then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Left) - end - if Proc.AffectedFaces.Right then - dMaxDiameter = min( dMaxDiameter, Proc.DistanceToNearestParts.Right) - end +local function VerifyPocket( Proc, nFacet, dElev, nRawId) local bForceClosedPocket = false - local bExcludeNoTipFeed = Proc.Topology == 'Pocket' + local b3Raw = EgtGetRawPartBBox( nRawId) + -- verifico se la feature è sul bordo (non ci sono altri pezzi davanti alla tasca). Se è sul bordo, l'utensile potrà attaccare da fuori. + local bIsFeatureOnEdge = ( Proc.Topology == 'Groove' and Proc.Fct == 4 and Proc.DistanceToNearestParts.Front > b3Raw:getDimY()) + + -- trovo il massimo diametro utensile ammissibile per la tasca + local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) + local dStartDiameter = min( dH, dV) + local dMaxDiameter = dStartDiameter + -- se una sola faccia posso usare un utensile più grande della faccia + if Proc.Fct == 1 then + dMaxDiameter = 2 * dMaxDiameter + end + -- se forma ad L posso usare un utensile più grande della faccia + local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2) + if bIsL then + dMaxDiameter = 2 * dMaxDiameter + end + -- se forma ad U riduco il diametro se necessario + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) + if bIsU then + -- prendo la linea di base + local dMiddleFacetLength = 0 + if abs( dElev - dH) < 1 and abs( dElev - dV) > 1 then + dMiddleFacetLength = dV + elseif abs( dElev - dV) < 1 and abs( dElev - dH) > 1 then + dMiddleFacetLength = dH + end + if dMiddleFacetLength > dMaxDiameter then + dMaxDiameter = min( 2 * dMaxDiameter, dMiddleFacetLength) + end + end + -- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile + if Proc.Fct == 3 and bIsL then + dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000) + elseif Proc.Fct >= 4 then + dMaxDiameter = min( dMaxDiameter, WD.MAXDIAM_POCK_CORNER or 1000) + end + + -- verifico la distanza minima dalle parti vicine e nel caso il FindPocketing limiterà il diametro massimo dell'utensile + local dDistanceToNearestPart = GEO.INFINITO + if Proc.AffectedFaces.Front then + dDistanceToNearestPart = Proc.DistanceToNearestParts.Front + end + if Proc.AffectedFaces.Back then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Back) + end + if Proc.AffectedFaces.Left then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Left) + end + if Proc.AffectedFaces.Right then + dDistanceToNearestPart = min( dDistanceToNearestPart, Proc.DistanceToNearestParts.Right) + end + -- se la distanza è inferiore ad un valore minimo forzo la tasca chiusa per evitare che la ricerca utensile fallisca + local dMinToolDiameter = 25 + if dDistanceToNearestPart < dMinToolDiameter / 2 - 10 * GEO.EPS_SMALL then + bForceClosedPocket = true + dDistanceToNearestPart = dMaxDiameter + end + + local bExcludeNoTipFeed = ( Proc.Topology == 'Pocket') -- recupero la lavorazione local bUseDElevToFindPocketing = true - local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) + local sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) -- se tasca troppo profonda cerco senza elevazione e limiterò la profondità if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) end local dMillDiam = 20 local dMaxDepth = 0 @@ -2217,7 +2266,7 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup @@ -2230,11 +2279,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) dMillDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dMillDiam end end - -- verifico se la lavorazione (o il suo eventuale doppio) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa - if IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) or - Proc.Double and Proc.Double > 0 and IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) then + -- verifico se la lavorazione (o il suo eventuale mirror) potrebbe danneggiare le parti limitrofe e devo quindi forzare una tasca chiusa + local bIsMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc, dMillDiam, nRawId) + if bIsMachiningDamagingOtherParts then bForceClosedPocket = true end + -- disattivo il doppio se devo forzare una tasca chiusa ma l'altra no + if Proc.Double and Proc.Double > 0 then + local bIsMirrorMachiningDamagingOtherParts = IsMachiningDamagingOtherParts( Proc.Mirror, dMillDiam, nRawId) + if bIsMachiningDamagingOtherParts ~= bIsMirrorMachiningDamagingOtherParts then + Proc.Double = 0 + end + end -- altrimenti diametro utensile troppo piccolo: devo forzare tasca chiusa else bForceClosedPocket = true @@ -2242,17 +2298,17 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) -- se tasca chiusa cerco lavorazione con diametro massimo pari a dimensione tasca e riverifico per eventuale doppio if bForceClosedPocket then - dMaxDiameter = min( dH, dV) + dMaxDiameter = dStartDiameter bUseDElevToFindPocketing = true - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, dElev, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) if not sPocketing then bUseDElevToFindPocketing = false - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, nil, nil, nil, bExcludeNoTipFeed, dDistanceToNearestPart) end -- se doppio cerco una lavorazione adatta if Proc.Double and Proc.Double == 2 then local sPocketingBackup = sPocketing - sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true) + sPocketing = WM.FindPocketing( 'Pocket', dMaxDiameter, EgtIf( bUseDElevToFindPocketing, dElev, nil), nil, 'H1', true, dDistanceToNearestPart) if not WM.IsMachiningOkForDouble( sPocketing) then Proc.Double = 0 sPocketing = sPocketingBackup @@ -2270,50 +2326,18 @@ local function VerifyPocket( Proc, dMaxDiameter, dElev, nRawId, dH, dV) end end - return sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam + return sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam end --------------------------------------------------------------------- local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) -- dati della faccia local ptC, vtN = EgtSurfTmFacetCenter( Proc.Id, nFacet, GDB_ID.ROOT) local dElev = WL.GetFaceElevation( Proc.Id, nFacet, nRawId) - local _, dH, dV = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - local dDiam = min( dH, dV) -- gruppo ausiliario local nAddGrpId = WL.GetAddGroup( Proc.PartId) - local nNewProc, nNumFacet = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet) - -- se una sola faccia - if Proc.Fct == 1 then - dDiam = 2 * dDiam - end - -- se forma ad L - local bIsL = ( Proc.Fct == 2 or WL.TestElleShape3( Proc.Id, Proc.Fct) or WL.TestElleShape4( Proc.Id, Proc.Fct) == 2) - if bIsL then - dDiam = 2 * dDiam - end - -- se forma ad U - local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) - if bIsU then - local _, dH2, dV2 = EgtSurfTmFacetMinAreaRectangle( Proc.Id, nFacet, GDB_ID.ROOT) - -- prendo la linea di base - local dMiddleFacetLength = 0 - if abs( dElev - dH2) < 1 and abs( dElev - dV2) > 1 then - dMiddleFacetLength = dV2 - elseif abs( dElev - dV2) < 1 and abs( dElev - dH2) > 1 then - dMiddleFacetLength = dH2 - end - if dMiddleFacetLength > dDiam then - dDiam = min( 2 * dDiam, dMiddleFacetLength) - end - end - -- in presenza di angoli interni, limito secondo impostazione globale il diametro massimo utensile - if Proc.Fct == 3 and bIsL then - dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) - elseif Proc.Fct >= 4 then - dDiam = min( dDiam, WD.MAXDIAM_POCK_CORNER or 1000) - end + local nNewProc = RemoveBottomFaceAndReorder( Proc, nAddGrpId, nFacet) -- cerco lavorazione adatta e recupero i dati utensile - local sPocketing, bForceClosedPocket, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, dDiam, dElev, nRawId, dH, dV) + local sPocketing, bForceClosedPocket, bIsFeatureOnEdge, sTuuid, dMillDiam, dMaxDepth, dThDiam = VerifyPocket( Proc, nFacet, dElev, nRawId) if not sPocketing then local sErr = 'Error : pocketing not found in library' EgtOutLog( sErr) @@ -2366,6 +2390,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) end -- setto eventuale nota per forzare tasca chiusa if bForceClosedPocket then sUserNotes = EgtSetValInNotes( sUserNotes, 'Open', 0) end + -- setto eventuale nota per forzare attacco esterno, fino ad un certo spessore del grezzo + local dMaxRawThicknessToStartOut = 75 + if bIsFeatureOnEdge and ( not Proc.Double or Proc.Double == 0) then sUserNotes = EgtSetValInNotes( sUserNotes, 'OpenMinSafe', dMaxRawThicknessToStartOut) end -- scrivo le note della lavorazione EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) -- eseguo @@ -2374,7 +2401,9 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) EgtSetOperationMode( nMchFId, false) return false, sErr end + -- verifica parametro Q per pulitura spigoli + local bIsU = ( Proc.Fct == 3 and not WL.TestElleShape3( Proc.Id, Proc.Fct)) if bCheckQPar and not ( bIsU and AreSameOrOppositeVectorApprox( vtN, Z_AX())) then -- lettura parametri (probabile/i parametro/i Q) local nConeCut = EvaluateQParam( Proc) @@ -2382,7 +2411,7 @@ local function MakeByPocketing( Proc, nFacet, nRawId, b3Raw, bCheckQPar) local vFace, dMaxWidth = GetFacesData( nNewProc, false, false, dMillDiam, dMaxDepth, (dMillDiam/2), nAddGrpId, Proc.PartId) -- se abilitata la lavorazione corner con stop macchina if nConeCut == 1 then - local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw, + local bMcok, sMcErr = AddMillCorner( nConeCut, vFace, Proc, nRawId, b3Raw, dMillDiam, nAddGrpId, dMaxWidth, nNewProc, dDepth) if not bMcok then return bMcok, sMcErr end elseif nConeCut == 2 then diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index fecc960..d0ee2ca 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -5,7 +5,6 @@ -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. --- 2023/10/30 In SetMirroredFeatures permesso il doppio per groove con specchiata non sul fianco se settate per essere lavorate come pocket. -- Tabella per definizione modulo local WallExec = {} @@ -797,7 +796,7 @@ local function SetMirroredFeatures( vProc, b3Raw) end end -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo - local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and ( bIsMirrorFeatureOnEdge or nDoubleType == 1)) or + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index f696beb..55e465e 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -506,7 +506,7 @@ function WallLib.GetProcessDistanceToNearestParts( Proc) end ------------------------------------------------------------------------------------------------------------- --- restituisce le distanze XY tra la feature Proc e il grezzo, secondo le direzioni Y-/Y+/X-/X+ +-- restituisce le distanze XY tra la feature Proc e il termine del grezzo, secondo le direzioni Y-/Y+/X-/X+ function WallLib.GetProcessDistanceToRawPart( Proc, b3Raw) local b3Proc = Proc.Box local ptMinProc = b3Proc:getMin() From e92ba3e74079733c22f1d66af9584e7da11faa06 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 Nov 2023 11:48:06 +0100 Subject: [PATCH 39/43] =?UTF-8?q?-=20In=20WallExec=20doppio=20disattivato?= =?UTF-8?q?=20se=20side=20e=20la=20lavorazione=20mirror=20=C3=A8=20troppo?= =?UTF-8?q?=20distante=20dal=20grezzo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LuaLibs/WallExec.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index d0ee2ca..cfaebf6 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -5,6 +5,7 @@ -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. +-- 2023/11/10 In SetMirroredFeatures doppio disattivato se side e la lavorazione mirror è troppo distante dal grezzo. -- Tabella per definizione modulo local WallExec = {} @@ -782,6 +783,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- se di fianco, si sceglie se le feature sono compatibili con il doppio e nel caso che tipo di lavorazione fare -- -1: no doppio, 0: nessuna preferenza, 1: pocket, 2: side (scambio faccia principale) local nDoubleType = 0 + local bAllowSideOnMirror = ( ProcMirror.DistanceToRawPart.Back - Proc.DistanceToRawPart.Front < 10 * GEO.EPS_SMALL) if bLapVsTop and ( Proc.AffectedFaces.Top or Proc.AffectedFaces.Bottom) then -- side if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then @@ -791,12 +793,13 @@ local function SetMirroredFeatures( vProc, b3Raw) -- no doppio elseif Proc.AffectedFaces.Bottom or ProcMirror.AffectedFaces.Bottom then nDoubleType = -1 + -- tasca else nDoubleType = 1 end end -- corrispondenza nella posizione delle feature. Se di fianco il lato master è sempre quello verso l'operatore, se sopra nessun vincolo - local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge) or + local bIsMirrorSideOk = ( bLapVsTop and ProcMirror.AffectedFaces.Back and bIsFeatureOnEdge and bIsMirrorFeatureOnEdge and bAllowSideOnMirror) or Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and ProcMirror.AffectedFaces.Top or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Left or Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Right and ProcMirror.AffectedFaces.Top and ProcMirror.AffectedFaces.Right or From d1ca35e29dc6ed838b8ffc46e05714ac6c05dee0 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 10 Nov 2023 15:11:28 +0100 Subject: [PATCH 40/43] correzione minore in WallExec -> SetMirroredFeatures --- LuaLibs/WallExec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index cfaebf6..231ead8 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -783,7 +783,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- se di fianco, si sceglie se le feature sono compatibili con il doppio e nel caso che tipo di lavorazione fare -- -1: no doppio, 0: nessuna preferenza, 1: pocket, 2: side (scambio faccia principale) local nDoubleType = 0 - local bAllowSideOnMirror = ( ProcMirror.DistanceToRawPart.Back - Proc.DistanceToRawPart.Front < 10 * GEO.EPS_SMALL) + local bAllowSideOnMirror = ( ProcMirror.DistanceToRawPart.Back - Proc.DistanceToRawPart.Front < 1 + 10 * GEO.EPS_SMALL) if bLapVsTop and ( Proc.AffectedFaces.Top or Proc.AffectedFaces.Bottom) then -- side if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then From da7d2a71598eaf824bbef9a0841bc16a0863c12e Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 13 Nov 2023 18:18:48 +0100 Subject: [PATCH 41/43] - in WallExec aggiunte al sorting le lavorazioni PreSideMill che vengono sempre fatte prima delle SideMill - LapJoint -> MakeSideGrooveByMill, se rabbet doppio uno verso l'alto e uno verso il basso, aggiunto step extra iniziale per ripulire la lamina che potrebbe rimanere nella rabbet che guarda in alto. --- LuaLibs/WProcessLapJoint.lua | 86 ++++++++++++++++++++++++++++++++++-- LuaLibs/WallExec.lua | 12 ++--- 2 files changed, 88 insertions(+), 10 deletions(-) diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index fa463d4..818e21c 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -36,6 +36,8 @@ -- 2023/11/07 In MakeByPocketing, se tasca che guarda davanti, aggiunta possibilità di attaccare fuori dal grezzo fino ad uno spessore di 75 mm. -- In MakeByPocketing calcolo del massimo diametro utensile spostato in VerifyPocketing. -- In MakeByPocketing il doppio viene ora disattivato se una tasca deve essere forzata chiusa e l'altra no. +-- 2023/11/13 In MakeSideGrooveByMill, se rabbet doppio uno verso l'alto e uno verso il basso, aggiunto step extra iniziale per ripulire la lamina che potrebbe rimanere nella rabbet che guarda in alto. + -- Tabella per definizione modulo local WPL = {} @@ -1521,10 +1523,14 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d end end -- se profondità ribasso è maggiore della capacità di sottosquadro dell'utensile - if ( not bEnablePreMill and ( bMachFromDn or Proc.Fct > 2)) and ( dElev > 0.5 * ( dMillDiam - dMillDiamTh) - 10 * GEO.EPS_SMALL) then - local sErr = 'Error : Side Elevation (' .. dElev .. ') bigger than max tool side depth (' .. ( 0.5 * ( dMillDiam - dMillDiamTh)) ..')' - EgtOutLog( sErr) - return false, sErr + if ( dElev > 0.5 * ( dMillDiam - dMillDiamTh) - 10 * GEO.EPS_SMALL) then + if ( not bEnablePreMill and ( bMachFromDn or Proc.Fct > 2)) then + local sErr = 'Error : Side Elevation (' .. dElev .. ') bigger than max tool side depth (' .. ( 0.5 * ( dMillDiam - dMillDiamTh)) ..')' + EgtOutLog( sErr) + return false, sErr + elseif Proc.Double then + Proc.Double = 0 + end end local dMillExtra = dMillTotLen - dMillLen if Proc.Box:getMin():getZ() - dMillExtra < b3Raw:getMin():getZ() - 10 * GEO.EPS_SMALL then @@ -1895,6 +1901,78 @@ local function MakeSideGrooveByMill( Proc, nFacet, nRawId, b3Raw, sCustomMach, d bUpwardMilling = true end + -- step extra in caso di doppio con mix rabbet dal basso e dall'alto, per eliminare la lamina che potrebbe rimanere + if Proc.Double and Proc.Double == 2 and Proc.Topology == 'Rabbet' and + not ( Proc.AffectedFaces.Bottom and Proc.Mirror.AffectedFaces.Bottom) and not ( Proc.AffectedFaces.Top and Proc.AffectedFaces.Bottom) then + -- determino a quale delle due feature applicare la lavorazione + local bProcVsMirrorToCopy = true + local nFacetToMachine = nFacet + if Proc.AffectedFaces.Bottom then + bProcVsMirrorToCopy = false + for i = 1, Proc.Mirror.Fct do + local vtNMirror = Proc.Mirror.Face[i].VtN + if AreOppositeVectorApprox( vtN, vtNMirror) then + nFacetToMachine = Proc.Mirror.Face[i].Id + break + end + end + end + local nAddGrpId = WL.GetAddGroup( EgtIf( bProcVsMirrorToCopy, Proc.PartId, Proc.Mirror.PartId)) + local nNewProc = EgtCopyGlob( EgtIf( bProcVsMirrorToCopy, Proc.Id, Proc.Mirror.Id), nAddGrpId) or GDB_ID.NULL + local NewProc = { Id = nNewProc, PartId = EgtIf( bProcVsMirrorToCopy, Proc.PartId, Proc.Mirror.PartId)} + -- lavorazione + local sName = 'PreSideMill_' .. EgtGetName( NewProc.Id) or tostring( NewProc.Id) + local nMchFId = WM.AddMachining( NewProc, sName, sMilling) + if not nMchFId then + local sErr = 'Error adding machining ' .. sName .. '-' .. sMilling + EgtOutLog( sErr) + return false, sErr + end + EgtSetInfo( nMchFId, 'Part', NewProc.PartId) + -- aggiungo geometria + EgtSetMachiningGeometry( {{ NewProc.Id, nFacetToMachine}}) + -- imposto posizione braccio porta testa + local nSCC = MCH_SCC.ADIR_NEAR + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + -- imposto modo di lavorare la faccia + local nFaceUse = WL.GetNearestParalOpposite( Z_AX()) + EgtSetMachiningParam( MCH_MP.FACEUSE, nFaceUse) + -- imposto elevazione e step + local dDepth = 5 + EgtSetMachiningParam( MCH_MP.DEPTH, dDepth) + EgtSetMachiningParam( MCH_MP.STEP, dElev) + -- setto il lato di lavoro standard + EgtSetMachiningParam( MCH_MP.INVERT, true) + EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) + -- setto allungamenti iniziali e finali + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dExtraLongIni) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dExtraLongEnd) + -- Confronto il raggio fresa con l'elevazione dalla normale per vedere se devo modificare l'uscita + if dElev > ( 0.5 * dMillDiam) then + -- setto allungamenti perpendicolari + EgtSetMachiningParam( MCH_MP.LIPERP, 0) + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + end + -- se richiesto, setto la nota per spostare la lavorazione alla fine + if not WD.SIDEMILL_BEFORE then + EgtSetInfo( nMchFId, 'MOVE_AFTER', 1) + end + -- eseguo + if not EgtApplyMachining( true, false) then + -- provo a invertire posizione braccio porta testa + nSCC = MCH_SCC.ADIR_FAR + EgtSetMachiningParam( MCH_MP.SCC, nSCC) + if not EgtApplyMachining( true, false) then + local _, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nMchFId, false) + return false, sErr + end + end + -- se faccio lo step extra e ho rimosso la lamina, in doppio lavorerò dal basso verso l'alto + bUpwardMilling = true + end + + -- lavorazione local dStepOri if not bExcludeSideMill then local nSideStep = 1 diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index 231ead8..ffae5ae 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -6,6 +6,7 @@ -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. -- 2023/11/10 In SetMirroredFeatures doppio disattivato se side e la lavorazione mirror è troppo distante dal grezzo. +-- 2023/11/13 Aggiunte le lavorazioni PreSideMill che vengono sempre fatte prima delle SideMill. -- Tabella per definizione modulo local WallExec = {} @@ -608,6 +609,8 @@ local function SortMachinings( nPhase, PrevMch, nPartId, nPriority) PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_MY.SURFFINISHING, nil, nil, 'MOVE_AFTER', false, nil, nil, nil, nPriority) -- Fresature per gole PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'Gorge_'}, true, 'MOVE_AFTER', false, nil, nil, nil, nPriority) + -- Fresature da fare prima delle SideMill + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'PreSideMill_'}, true, 'MOVE_AFTER', false, false, true, true, nPriority) -- Fresature che sono rifiniture di spigoli PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'SideMill_'}, true, 'MOVE_AFTER', false, false, true, true, nPriority) -- Fresature che sono puliture di spigoli @@ -618,6 +621,8 @@ local function SortMachinings( nPhase, PrevMch, nPartId, nPriority) PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.SAWING, nil, nil, nil, nil, nil, nil, nil, nPriority) -- Qui rimozione sfridi (se ci sono lavorazioni successive) if not nPriority then + -- Fresature da fare prima delle SideMill + PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'PreSideMill_'}, true, 'MOVE_AFTER', true, false, true, true) -- Fresature dei lapjoint che necessitano di gorge PrevMch = SortMach( nPhase, PrevMch, nPartId, MCH_OY.MILLING, { 'SideMill_'}, true, 'MOVE_AFTER', true, false, true, true) -- Tagli con sega a catena che vanno fatti dopo i tagli con lama @@ -783,7 +788,7 @@ local function SetMirroredFeatures( vProc, b3Raw) -- se di fianco, si sceglie se le feature sono compatibili con il doppio e nel caso che tipo di lavorazione fare -- -1: no doppio, 0: nessuna preferenza, 1: pocket, 2: side (scambio faccia principale) local nDoubleType = 0 - local bAllowSideOnMirror = ( ProcMirror.DistanceToRawPart.Back - Proc.DistanceToRawPart.Front < 1 + 10 * GEO.EPS_SMALL) + local bAllowSideOnMirror = ( ProcMirror.DistanceToRawPart.Back - Proc.DistanceToRawPart.Front < 1 + 10 * GEO.EPS_SMALL) or ( not WD.SIDEMILL_BEFORE and ( not Proc.AffectedFaces.Top or not ProcMirror.AffectedFaces.Top)) if bLapVsTop and ( Proc.AffectedFaces.Top or Proc.AffectedFaces.Bottom) then -- side if bIsFeatureOnEdge and bIsMirrorFeatureOnEdge then @@ -1119,11 +1124,6 @@ function WallExec.ProcessFeatures() end EgtOutLog( ' *** End AddMachinings ***', 1) - ------- - -- LAVORAZIONI IN DOPPIO - QUI INSERIRE: - -- VERIFICA E UPDATE NOTE PER LAVORAZIONI IN CUI SI CONTROLLA SE I PERCORSI SONO SPECCHIATI - ------- - -- setto quali sono le lavorazioni da disattivare perchè specchiate di lavorazioni in doppio local vProcToDisable = {} for i = 1, #vProc do From 29a2ec8bae0d8b254ee1706a354b6262b3e576df Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 Nov 2023 18:50:06 +0100 Subject: [PATCH 42/43] aggiunta commenti --- LuaLibs/WMachiningLib.lua | 7 +------ LuaLibs/WProcessDoubleCut.lua | 1 + LuaLibs/WProcessDrill.lua | 1 + LuaLibs/WProcessFreeContour.lua | 3 ++- LuaLibs/WProcessLapJoint.lua | 9 ++------- LuaLibs/WallExec.lua | 4 ++-- LuaLibs/WallLib.lua | 1 + 7 files changed, 10 insertions(+), 16 deletions(-) diff --git a/LuaLibs/WMachiningLib.lua b/LuaLibs/WMachiningLib.lua index 1595e2c..d4cbf8d 100644 --- a/LuaLibs/WMachiningLib.lua +++ b/LuaLibs/WMachiningLib.lua @@ -3,13 +3,8 @@ -- 2023/03/09 Piccola correzione alla SideDepth in FindMilling -- In FindMilling aggiunta gestione spessore e massimo materiale nel caso di lam -- 2023/05/25 Aggiunta funzione AddMachining che incapsula EgtAddMachining trascrivendo le priorità btl dalle feature alle lavorazioni. --- 2023/06/07 Alla funzione AddMachining aggiunta la scrittura di alcune info alle lavorazioni. --- 2023/07/13 In FindMilling, FindPocketing aggiunta la possibilità di limitare la ricerca lavorazioni alla sola testa specificata. -- 2023/10/18 In SetCurrMachiningAndTool sostituito controllo di utensile attivo con controllo utensile nel setup corrente. --- 2023/10/30 In FindPocketing aggiunto parametro per poter escludere le frese che non lavorano di testa. --- 2023/10/31 In IsToolDoubleOk permessa una lunghezza lievemente inferiore dell'utensile secondario rispetto al principale. --- 2023/10/31 In FindPocketing le lavorazioni con attacco speciale (rampa molto lunga e step basso) ignorano il flag per escludere le frese che non lavorano di testa. --- 2023/11/06 In FindPocketing aggiunto parametro dDistanceToNearestPart per ridurre il massimo diametro in caso di altro pezzo troppo vicino. +-- 2023/11/14 Modifiche sostanziali per l'aggiunta delle lavorazioni in doppio e per il miglioramento nella gestione delle tasche. -- Tabella per definizione modulo local WMachiningLib = {} diff --git a/LuaLibs/WProcessDoubleCut.lua b/LuaLibs/WProcessDoubleCut.lua index 05a35e3..a4ee365 100644 --- a/LuaLibs/WProcessDoubleCut.lua +++ b/LuaLibs/WProcessDoubleCut.lua @@ -1,6 +1,7 @@ -- WProcessDoubleCut.lua by Egaltech s.r.l. 2023/04/17 -- Gestione calcolo doppi tagli di lama per Pareti -- 2023/04/17 Quando si chiama LapJoint si trasforma il Gruppo da 1 a 3 e da 2 a 4. +-- 2023/11/14 Aggiunta funzione IdentifyStrict per il riconoscimento della sola feature L011. -- Tabella per definizione modulo local WPDC = {} diff --git a/LuaLibs/WProcessDrill.lua b/LuaLibs/WProcessDrill.lua index a273ef1..b2e01aa 100644 --- a/LuaLibs/WProcessDrill.lua +++ b/LuaLibs/WProcessDrill.lua @@ -9,6 +9,7 @@ -- 2022/02/22 ES Aggiunta gestione prefori. -- 2022/03/08 DS Vanno accettati fori orizzontali sul bordo anche senza foratori orizzontali speciali. -- 2023/05/25 Funzioni EgtAddMachining sostituite da WM.AddMachining in modo da trascrivere le priorità da btl alle lavorazioni. +-- 2023/11/14 Aggiunta gestione forature in doppio. -- Tabella per definizione modulo local WPD = {} diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index c95d2a1..9a0ebbb 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -20,12 +20,13 @@ -- 2023/04/17 Lavorazione CleanCorner sempre forzata con lato di lavoro in centro. -- 2023/05/25 Funzioni EgtAddMachining sostituite da WM.AddMachining in modo da trascrivere le priorità da btl alle lavorazioni. -- 2023/06/06 Aggiunta gestione lavorazione per lamatura speciale affondata con Tool_ID specifico. --- 2023/06/26 Funzione Is3EdgesApprox spostata in WallLib. -- 2023/07/26 In MakeByCut migliorata la scelta della fresa secondaria nel caso non sia disponibile una fresa di lunghezza sufficiente. -- 2023/09/12 Modifiche a GetTunnelDimension (asse deve essere com Z globale) e MakeLocalSurf per gestire finestre con lati inclinati. -- 2023/09/21 In MakeByMill modificato SCC per correggere caso con lama su testa fresa. -- 2023/09/26 In Is3EdgesApprox aggiunta cancellazione dei loop temporanei. -- 2023/10/02 Correzione a MakeCustomPath per calcolare correttamente puliture spigoli di tipo 2 (Clean 30) e 3 (Gola di Scarico). +-- 2023/11/14 Spostamento di alcune funzioni in WallLib. +-- Aggiunta dei FreeContour in doppio. -- Tabella per definizione modulo local WPF = {} diff --git a/LuaLibs/WProcessLapJoint.lua b/LuaLibs/WProcessLapJoint.lua index 818e21c..6a43f81 100644 --- a/LuaLibs/WProcessLapJoint.lua +++ b/LuaLibs/WProcessLapJoint.lua @@ -30,13 +30,8 @@ -- 2023/09/21 Modifica controllo lavorabilità con tre facce tipo tunnel ma non ortogonali tra loro. -- 2023/09/21 In MakeByMill modificato SCC per correggere caso con lama su testa fresa. -- 2023/10/02 Aggiunta segnalazione lavorazione tipo Side non trovata. --- 2023/10/30 In VerifyPocket, per tasche in doppio forzata ricerca fresa che possa lavorare di testa. --- 2023/10/31 In VerifyPocket, se topologia pocket, forzata ricerca fresa che possa lavorare di testa. --- 2023/11/06 In VerifyPocket controllo massimo diametro in base a distanza pezzo più vicino demandato a FindPocketing. --- 2023/11/07 In MakeByPocketing, se tasca che guarda davanti, aggiunta possibilità di attaccare fuori dal grezzo fino ad uno spessore di 75 mm. --- In MakeByPocketing calcolo del massimo diametro utensile spostato in VerifyPocketing. --- In MakeByPocketing il doppio viene ora disattivato se una tasca deve essere forzata chiusa e l'altra no. --- 2023/11/13 In MakeSideGrooveByMill, se rabbet doppio uno verso l'alto e uno verso il basso, aggiunto step extra iniziale per ripulire la lamina che potrebbe rimanere nella rabbet che guarda in alto. +-- 2023/11/14 Aggiunta tasche in doppio. +-- Miglioramenti sostanziali nella gestione delle tasche. -- Tabella per definizione modulo local WPL = {} diff --git a/LuaLibs/WallExec.lua b/LuaLibs/WallExec.lua index ffae5ae..4ffabc6 100644 --- a/LuaLibs/WallExec.lua +++ b/LuaLibs/WallExec.lua @@ -5,8 +5,8 @@ -- 2023/06/27 Aggiunte origini TN e BN. -- 2023/07/04 Se c'è funzione di macchina WD.GetOrigCorner si lascia scegliere posizione default a questa impostando 0 se non c'è 'REFPOS'. -- 2023/10/16 Aggiunta gestione Aree vietate (LockOut) per chiodature. --- 2023/11/10 In SetMirroredFeatures doppio disattivato se side e la lavorazione mirror è troppo distante dal grezzo. --- 2023/11/13 Aggiunte le lavorazioni PreSideMill che vengono sempre fatte prima delle SideMill. +-- 2023/11/14 Modifiche sostanziali per l'aggiunta delle lavorazioni in doppio. +-- In Collect aggiunto il recupero preliminare di varie informazioni sulla feature. -- Tabella per definizione modulo local WallExec = {} diff --git a/LuaLibs/WallLib.lua b/LuaLibs/WallLib.lua index 55e465e..485adaa 100644 --- a/LuaLibs/WallLib.lua +++ b/LuaLibs/WallLib.lua @@ -1,6 +1,7 @@ -- WallLib.lua by Egaltech s.r.l. 2023/10/16 -- Libreria globale per Pareti -- 2023/06/26 Spostata qui Is3EdgesApprox da FreeContour. Ora cerca autonomamente il gruppo se non viene passato. +-- 2023/11/14 Aggiunte funzioni GetProcessAffectedFaces, GetProcessDistanceToNearestParts, GetProcessDistanceToRawPart. -- Tabella per definizione modulo local WallLib = {} From 15c80a86283f28366bc14a093240104b3688b346 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 14 Nov 2023 18:54:46 +0100 Subject: [PATCH 43/43] update log e versione --- UpdateLog.txt | 4 ++++ Version.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/UpdateLog.txt b/UpdateLog.txt index 35b4bd6..aa988f9 100644 --- a/UpdateLog.txt +++ b/UpdateLog.txt @@ -1,5 +1,9 @@ ==== Wall Update Log ==== +Versione 2.5k1 (14/11/2023) +- Added : aggiunte lavorazioni in doppio. +- Modif : miglioramenti vari alla lavorazione tasche, in particolare in presenza di pezzi vicini. + Versione 2.5j3 (23/10/2023) - Added : aggiunta gestione aree vietate per chiodature (LockOut for Nail) - Modif : in FreeContour conversione automatica di facce non fattibili con lama per limiti di orientamento in facce da fare con fresa. diff --git a/Version.lua b/Version.lua index 952613c..96fd52b 100644 --- a/Version.lua +++ b/Version.lua @@ -2,5 +2,5 @@ -- Gestione della versione di Wall NAME = 'Wall' -VERSION = '2.5j3' +VERSION = '2.5k1' MIN_EXE = '2.5b3'