diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 91efe82..94fef1e 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -650,6 +650,8 @@ local function CollectFeatures( Part) else EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') end + -- calcolo riduzione lunghezza pinzabile testa/coda + Proc.NotClampableLength = FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) -- altrimenti errore (serviva riconoscimento topologico, ma non è stato possibile farlo) else EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index d266227..6661f23 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -626,5 +626,6 @@ do return MergeSort( List, Compare) end end + ------------------------------------------------------------------------------------------------------------- return BeamLib diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index 0ae6034..cdc9205 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -293,8 +293,8 @@ function FeatureLib.CalculateCompositeRating( StrategyResult) end ------------------------------------------------------------------------------------------------------------- -function FeatureLib.MachiningNeedsSplitting( dMachiningLengthOnX, Part, OptionalParameters) - local bMachiningNeedsSplitting +function FeatureLib.IsMachiningLong( dMachiningLengthOnX, Part, OptionalParameters) + local bIsMachiningLong -- parametri opzionali if not OptionalParameters then @@ -302,10 +302,10 @@ function FeatureLib.MachiningNeedsSplitting( dMachiningLengthOnX, Part, Optional end local dMaxSegmentLength = OptionalParameters.dMaxSegmentLength or BeamData.LONGCUT_MAXLEN - bMachiningNeedsSplitting = ( dMachiningLengthOnX > dMaxSegmentLength + 10 * GEO.EPS_SMALL) - or ( dMachiningLengthOnX > 0.7 * Part.b3Part:getDimX() + 10 * GEO.EPS_SMALL) + bIsMachiningLong = ( dMachiningLengthOnX > dMaxSegmentLength + 10 * GEO.EPS_SMALL) + or ( dMachiningLengthOnX > 0.7 * Part.b3Part:getDimX() + 10 * GEO.EPS_SMALL) - return bMachiningNeedsSplitting + return bIsMachiningLong end ------------------------------------------------------------------------------------------------------------- @@ -327,7 +327,7 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) local dToolOverlapBetweenSegments = OptionalParameters.dToolOverlapBetweenSegments or BeamData.MILL_OVERLAP -- verifica spezzatura necessaria - if not FeatureLib.MachiningNeedsSplitting( Proc.b3Box:getDimX(), Part) then + if not FeatureLib.IsMachiningLong( Proc.b3Box:getDimX(), Part) then return {} end @@ -405,5 +405,100 @@ function FeatureLib.GetAdditionalInfo( Proc, Part) return Proc end +------------------------------------------------------------------------------------------------------------- +function FeatureLib.GetFeatureVolume( Proc, Part) + local dProcVolume = 0 + + local nAddGrpId = BeamLib.GetAddGroup( Proc.idPart) + if not nAddGrpId then + -- TODO gestire meglio questo errore. Non conviene creare e verificare all'inizio se il gruppo esiste? + EgtOutLog( 'Error : missing AddGroup') + return 0 + end + + local idProcCopy = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL + local b3PartCopy = BBox3d( Part.b3Part) + b3PartCopy:expand( -100 * GEO.EPS_SMALL) + local idPartCopy = EgtSurfTmBBox( nAddGrpId, b3PartCopy , false, GDB_RT.GLOB) + + EgtSurfTmSubtract( idPartCopy, idProcCopy) + dProcVolume = EgtSurfVolume( idPartCopy) + + EgtErase( { idProcCopy, idPartCopy}) + + return dProcVolume +end + +------------------------------------------------------------------------------------------------------------- +-- TODO bisogna calcolarla per tutte le rotazioni; funzione copiata direttamente da automatismo vecchio, da migliorare / completare +function FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) + local NotClampableLength = {} + + -- verifico siano una o due facce + if Proc.nFct > 2 then return end + + -- eventuale segnalazione ingombro di testa o coda + local dMinHIng = min( 0.5 * BeamData.VICE_MINH, 0.5 * Part.b3Raw:getDimZ()) + local dMinZ = max( BeamData.MIN_HEIGHT, 0.35 * Part.b3Raw:getDimZ()) + -- calcolo punto massimo in Z fino a dove considerare il pinzaggio. Minimo tra pinzaggio massimo e altezza pezzo + local dMaxHZ = Part.b3Raw:getMin():getZ() + min( BeamData.VICE_MAXH or BeamData.MAX_HEIGHT, Part.b3Raw:getDimZ()) + -- punto massimo in Z considerando anche la Z della feature + local dMaxHZFeat = min( dMaxHZ, Proc.b3Box:getMax():getZ()) + -- dimensione Z del pinzaggio (differenza massima Z pinzabile e box feature) + local dDeltaZClamp = ( ( dMaxHZ - Part.b3Raw:getMin():getZ()) - max( 0, dMaxHZFeat - Proc.b3Box:getMin():getZ())) + -- se pinzaggio minimo è come il massimo (oppure come l'altezza massima del pezzo) significa che è verticale + local bIsVertClamps = BeamData.VICE_MINH > BeamData.MAX_HEIGHT - 100 * GEO.EPS_SMALL + + -- condizioni per limitare pinzaggio testa/coda + local bUpdateIng = true + -- se dimensione del box della feature maggiore di metà pinzaggio minimo o metà spessore pezzo + bUpdateIng = bUpdateIng and Proc.b3Box:getDimZ() > dMinHIng + -- se la feature si trova più in basso del minimo pinzabile in Z o il 35% dello spessore pezzo + bUpdateIng = bUpdateIng and Proc.b3Box:getMin():getZ() < Part.b3Raw:getMin():getZ() + dMinZ + -- se feature è al di sotto del pinzaggio massimo + bUpdateIng = bUpdateIng and Proc.b3Box:getMin():getZ() < dMaxHZ + -- se ho le morse verticali, o se la feature è in centro o verso alto, controllo se non prendo abbastanza. + if bIsVertClamps or ( Proc.b3Box:getMin():getZ() - Part.b3Raw:getMin():getZ()) > BeamData.MIN_HEIGHT then + bUpdateIng = bUpdateIng and dDeltaZClamp < BeamData.VICE_MINH + end + + local dNotClampableLengthHead = 0 + local dNotClampableLengthTail = 0 + + if bUpdateIng then + if Proc.AffectedFaces.bRight then + local dOffs = Part.b3Part:getMax():getX() - Proc.b3Box:getMin():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + dNotClampableLengthHead = dOffs + elseif Proc.AffectedFaces.bLeft then + local dOffs = Proc.b3Box:getMax():getX() - Part.b3Part:getMin():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + dNotClampableLengthTail = dOffs + elseif Proc.b3Box:getCenter():getX() > Part.b3Part:getCenter():getX() then + local dOffs = Part.b3Part:getMax():getX() - Proc.b3Box:getMin():getX() + local dDist = Part.b3Part:getMax():getX() - Proc.b3Box:getMax():getX() + -- se pinze a 45° e pinza abbastanza materiale, compenso comunque, ma solo inclinazione morse + if not bIsVertClamps and dDeltaZClamp > BeamData.VICE_MINH and BeamData.VICE_MAXH then + dOffs = min( dOffs, BeamData.VICE_MAXH - BeamData.VICE_MINH) + end + -- dDist serve?? + dNotClampableLengthHead = dOffs + end + end + + NotClampableLength.Rot0 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot90 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot180 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + NotClampableLength.Rot270 = { Head = dNotClampableLengthHead, Tail = dNotClampableLengthTail} + + return NotClampableLength +end + ------------------------------------------------------------------------------------------------------------- return FeatureLib \ No newline at end of file diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index b1b92ee..751d981 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -116,7 +116,7 @@ function MachiningLib.GetSplitMachinings( Machinings, SplittingPoints, Part ) end local dOriginalStartAddLength = Machinings[i].LeadIn.dStartAddLength local dOriginalEndAddLength = Machinings[i].LeadOut.dEndAddLength - if FeatureLib.MachiningNeedsSplitting( Machinings[i].dLengthOnX, Part) then + if FeatureLib.IsMachiningLong( Machinings[i].dLengthOnX, Part) then local nCurrentMachiningIndex = i -- lo spezzone attivo è quello precedente al punto di spezzatura corrente for j = 1, nParts do diff --git a/Strategies/Standard/STR0002/STR0002.lua b/Strategies/Standard/STR0002/STR0002.lua index 247a40b..f3cb106 100644 --- a/Strategies/Standard/STR0002/STR0002.lua +++ b/Strategies/Standard/STR0002/STR0002.lua @@ -1,7 +1,7 @@ -- Strategia: STR0002 -- Descrizione -- Svuotatura tasca --- Feature tipo LapJpint +-- Feature tipo LapJoint ------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------- diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 042aa6e..205921c 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -3,6 +3,16 @@ -- Lama + motosega per slot -- Feature: tipo lapjoint +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +-- TODO +-- 1 - Gestire lavorazioni da sotto +-- 2 - Inserire antischeggia (fresa o lama) +-- 3 - Smusso a V +-- 4 - Implementare lavorazione di geometrie inclinate +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- + -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') @@ -233,7 +243,6 @@ end function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0003\\STR0003Config') diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 9c9429e..84a2d9f 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -3,6 +3,16 @@ -- motosega per slot -- Feature: tipo lapjoint +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- +-- TODO +-- 1 - Inserire antischeggia (fresa o lama) +-- 2 - Smusso a V +-- 3 - Implementare lavorazione di geometrie inclinate +-- 4 - Gestire lavorazioni da sotto (ove possibile, in generale la motosega non lavora da sotto) +------------------------------------------------------------------------------------------------------------- +------------------------------------------------------------------------------------------------------------- + -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') @@ -122,7 +132,6 @@ end function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0004\\STR0004Config') diff --git a/Strategies/Standard/STR0005/STR0005.lua b/Strategies/Standard/STR0005/STR0005.lua index 7e026ce..6096092 100644 --- a/Strategies/Standard/STR0005/STR0005.lua +++ b/Strategies/Standard/STR0005/STR0005.lua @@ -1,7 +1,7 @@ -- Strategia: STR0005 -- Descrizione -- lama per taglio facce con cubetti se necessario --- Feature: tagli singoli / doppi +-- Feature: tagli singoli con eventuali cubetti -- carico librerie local BeamLib = require( 'BeamLib') @@ -9,7 +9,7 @@ local BeamData = require( 'BeamData') local MachiningLib = require( 'MachiningLib') local FeatureLib = require( 'FeatureLib') -- strategie di base -local FaceByBlade = require( 'FACEBYBLADE') +local BladeToWaste = require( 'BLADETOWASTE') -- Tabella per definizione modulo local STR0005 = {} @@ -17,22 +17,28 @@ local Strategy = {} ------------------------------------------------------------------------------------------------------------- -local function IsTopologyOk( Proc) - if Proc.Topology.bAllRightAngles and - ( Proc.Topology.sName == 'Pocket-5-Blind' or - Proc.Topology.sName == 'Groove-3-Through' or - Proc.Topology.sName == 'Groove-4-Blind' or - Proc.Topology.sName == 'Tunnel-4-Through') then +local function GetBestCuttingStrategy( Proc, Part, StrategyParameters) + local sCuttingStrategy = '' + local dFeatureVolume = FeatureLib.GetFeatureVolume( Proc, Part) + local dFeatureMaxDimension = max( Proc.b3Box:getDimX(), Proc.b3Box:getDimY(), Proc.b3Box:getDimZ()) + local dFeatureMaxNotClampableLengthHead = max( Proc.NotClampableLength.Rot0.Head, Proc.NotClampableLength.Rot90.Head, Proc.NotClampableLength.Rot180.Head, Proc.NotClampableLength.Rot270.Head) + local dFeatureMaxNotClampableLengthTail = max( Proc.NotClampableLength.Rot0.Tail, Proc.NotClampableLength.Rot90.Tail, Proc.NotClampableLength.Rot180.Tail, Proc.NotClampableLength.Rot270.Tail) - return true + if dFeatureVolume < StrategyParameters.dMaxWasteVolume + 10 * GEO.EPS_SMALL + and dFeatureMaxDimension < StrategyParameters.dMaxWasteLength + 10 * GEO.EPS_SMALL then + -- TODO non sto considerando se l'utensile (non ancora scelto) ci arriva o no! + sCuttingStrategy = 'DROP_WHOLE_WASTE' + elseif FeatureLib.IsMachiningLong( max( dFeatureMaxNotClampableLengthHead, dFeatureMaxNotClampableLengthTail), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN}) then + sCuttingStrategy = 'LEAVE_WASTE_ATTACHED' else - return false + sCuttingStrategy = 'DICE_CUT' end + + return sCuttingStrategy end function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) - -- TODO da implementare gestione feature lunghe e spezzatura -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0005\\STR0005Config') @@ -42,12 +48,23 @@ function STR0005.Make( bAddMachining, Proc, Part, CustomParameters) Strategy.Result = {} Strategy.Result.sInfo = '' - if not IsTopologyOk( Proc) then - local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' - EgtOutLog( sErr) - Strategy.Result.sStatus = 'Not-Applicable' - Strategy.Result.sInfo = 'Topology' - return false, Strategy.Result + local Cutting = {} + local sCuttingStrategy = '' + + if Strategy.Parameters.sCuttingStrategy == 'AUTO' then + sCuttingStrategy = GetBestCuttingStrategy( Proc, Part, Strategy.Parameters) + else + sCuttingStrategy = Strategy.Parameters.sCuttingStrategy + end + + if sCuttingStrategy == 'DROP_WHOLE_WASTE' then + + elseif sCuttingStrategy == 'LEAVE_WASTE_ATTACHED' then + + elseif sCuttingStrategy == 'DICE_CUT' then + + else + -- strategia di taglio non riconosciuta end return bAreAllMachiningsAdded, Strategy.Result diff --git a/Strategies/Standard/STR0005/STR0005Config.lua b/Strategies/Standard/STR0005/STR0005Config.lua index 133f644..895b570 100644 --- a/Strategies/Standard/STR0005/STR0005Config.lua +++ b/Strategies/Standard/STR0005/STR0005Config.lua @@ -1,5 +1,7 @@ -- Parametri configurabili da cliente per strategia: STR0004 +-- TODO - sostituire dMaxWasteVolume con dMaxWasteWeight? Dove prendere la densità del materiale? + local STR0005Data = { sStrategyId = 'STR0005', Parameters = { @@ -8,7 +10,14 @@ local STR0005Data = { { sName = 'sCanDamageNextPiece', sNameNge = 'DAMAGE_NEXT_PIECE', sValue = 'NEVER', sType = 'combo', sMinUserLevel = '1', Choices = { sValue = 'NEVER', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, { sValue = 'ONLY_IF_RAWPART', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, - { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}} + { sValue = 'ALWAYS', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sName = 'sCuttingStrategy', sNameNge = 'CUTTING_STRATEGY', sValue = 'AUTO', sType = 'combo', sMinUserLevel = '1', + Choices = { sValue = 'AUTO', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'DROP_WHOLE_WASTE', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'LEAVE_WASTE_ATTACHED', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}, + { sValue = 'DICE_CUT', sDescriptionShort = '', sDescriptionLong = '', sMessageId = ''}}, + { sName = 'dMaxWasteLength', sNameNge = 'MAX_WASTE_LENGTH', sValue = '300', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'}, + { sName = 'dMaxWasteVolume', sNameNge = 'MAX_WASTE_VOLUME', sValue = '6000000', sDescriptionShort = '', sDescriptionLong = '', sType = 'd', sMessageId = '', sMinUserLevel = '1'} } } diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua new file mode 100644 index 0000000..b40f145 --- /dev/null +++ b/StrategyLibs/BLADETOWASTE.lua @@ -0,0 +1,17 @@ +-- BLADETOWASTE.lua by Egalware s.r.l. 2025/01/08 +-- Libreria di supporto a strategie con funzioni comune a strategie diverse. + +-- Tabella per definizione modulo +local BLADETOWASTE = {} + +-- Include +require( 'EgtBase') + +-- Carico i dati globali +local BeamData = require( 'BeamData') +local FeatureLib = require( 'FeatureLib') +local MachiningLib = require( 'MachiningLib') +-- strategie di base +local FaceByBlade = require('FACEBYBLADE') + +EgtOutLog( ' BLADETOWASTE started', 1)