From 7165db47f63ce0a72971db2d2cd62dc6eaa5194d Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 17 May 2024 18:45:36 +0200 Subject: [PATCH 1/5] - modifiche per aggiunta strategia BladePlusChain - in BeamExec versione primordiale di FindBlade --- LuaLibs/BasicCustomerStrategies.lua | 112 +++- LuaLibs/BeamExec.lua | 6 +- LuaLibs/FaceData.lua | 7 +- LuaLibs/MachiningLib.lua | 60 ++- Strategies/STR0002/STR0002.lua | 4 +- Strategies/STR0003/STR0003.lua | 757 +++++++++++++++++++++++++++ Strategies/STR0003/STR0003Config.lua | 11 + Strategies/Strategies.ini | 43 +- 8 files changed, 948 insertions(+), 52 deletions(-) create mode 100644 Strategies/STR0003/STR0003.lua create mode 100644 Strategies/STR0003/STR0003Config.lua diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index de03953..0ce73e1 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -56,17 +56,25 @@ local function GetStrategies_Egalware( Proc) -- Feature : Slot elseif ID.IsSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Front Slot elseif ID.IsFrontSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Birds Mouth @@ -78,25 +86,37 @@ local function GetStrategies_Egalware( Proc) -- Feature : Ridge Lap elseif ID.IsRidgeLap( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Lap Joint elseif ID.IsLapJoint( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Notch/Rabbet elseif ID.IsNotchRabbet( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Block Haus @@ -105,9 +125,13 @@ local function GetStrategies_Egalware( Proc) -- Feature : Notch elseif ID.IsNotch( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : French Ridge Lap @@ -125,9 +149,13 @@ local function GetStrategies_Egalware( Proc) -- Feature : Pocket elseif ID.IsPocket( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Drilling @@ -268,17 +296,25 @@ local function GetStrategies_Essetre( Proc) -- Feature : Slot elseif ID.IsSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Front Slot elseif ID.IsFrontSlot( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Birds Mouth @@ -290,25 +326,37 @@ local function GetStrategies_Essetre( Proc) -- Feature : Ridge Lap elseif ID.IsRidgeLap( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Lap Joint elseif ID.IsLapJoint( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Notch/Rabbet elseif ID.IsNotchRabbet( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Block Haus @@ -317,9 +365,13 @@ local function GetStrategies_Essetre( Proc) -- Feature : Notch elseif ID.IsNotch( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : French Ridge Lap @@ -337,9 +389,13 @@ local function GetStrategies_Essetre( Proc) -- Feature : Pocket elseif ID.IsPocket( Proc) then if Proc.Topology.sName == 'Pocket-5-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} elseif Proc.Topology.sName == 'Groove-4-Blind' then - Strategies = { { sStrategyId = 'STR0002'}} + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Groove-3-Through' then + Strategies = { { sStrategyId = 'STR0002'}, { sStrategyId = 'STR0003'}} + elseif Proc.Topology.sName == 'Tunnel-4-Through' then + Strategies = { { sStrategyId = 'STR0003'}} end --------------------------------------------------------------------- -- Feature : Drilling diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 06c00c5..544a4d5 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -17,7 +17,7 @@ local ID = require( 'Identity') local BCS = require( 'BasicCustomerStrategies') local FeatureData = require( 'FeatureData') local FaceData = require( 'FaceData') -local MachLib = require( 'MachiningLib') +local MachiningLib = require( 'MachiningLib') EgtOutLog( ' BeamExec started', 1) @@ -153,8 +153,8 @@ function BeamExec.GetToolsFromDB() Tool.dDistance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena Tool.bIsMortise = EgtGetValInNotes( Tool.sUserNotes, 'MORTISE') == 1 Tool.bIsChainSaw = not Tool.bIsMortise - Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or ( Tool.dThick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza - Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza + Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or floor( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza + Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or ( Tool.dThick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza end end diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index b40d5f4..a7af641 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -120,6 +120,7 @@ function FaceData.GetFacesInfo( Proc, Part) local frHV, dFaceWidth, dFaceHeight = BeamLib.GetFaceHvRefDim( Proc.id, i - 1, Part) -- frame OCS faccia Faces[i].vtFrameHV = frHV + -- TODO valutare se Width e Height si possono rimuovere -- larghezza OCS faccia Faces[i].dWidth = dFaceWidth -- altezza OCS faccia @@ -195,6 +196,7 @@ local function GetTunnelFaces( Proc) EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.id, Proc.Faces[i].ptCenter, -Proc.Faces[i].vtN, false, GDB_ID.ROOT) end TunnelAddedFaces.MiddleFaceTm.Type = 'Tunnel' + -- TODO aggiungere anche informazioni Edges tunnel?? return TunnelAddedFaces end @@ -379,6 +381,8 @@ local function GetSideFaces( Proc, MainFaces) error( 'GetSideFaces : Topology not implemented') end + -- TODO da sistemare come Bottom e Long + local idBottomFace = GDB_ID.NULL if Proc.Topology.sFamily ~= 'Tunnel' then if MainFaces.BottomFace then @@ -396,7 +400,6 @@ local function GetSideFaces( Proc, MainFaces) LongFaces = GetLongFaces( Proc, MainFaces) end - for i = 1, Proc.nFct do if not idBottomFace or i ~= ( idBottomFace + 1) then local bIsSideFace = true @@ -413,6 +416,8 @@ local function GetSideFaces( Proc, MainFaces) end end + -- TODO aggiungere anche informazioni Edges?? + return SideFaces end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index c52a2f8..2936a94 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -53,6 +53,19 @@ local function GetToolEntryAngle( Proc, vtTool) end +------------------------------------------------------------------------------------------------------------- +function MachiningLib.GetMachiningSteps( dMachiningDepth, dStep) + + local MachiningSteps = {} + MachiningSteps.StepLength = 0 + MachiningSteps.Count = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) + if MachiningSteps.Count > 1 then + MachiningSteps.StepLength = ( dMachiningDepth - dStep) / ( MachiningSteps.Count - 1) + end + + return MachiningSteps +end + ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo FRESA con certe caratteristiche function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, vtToolDir) @@ -81,8 +94,7 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d -- calcolo riduzione del massimo materiale utilizzabile local dToolEntryAngle = GetToolEntryAngle( Proc, vtToolDir) -- se ToolHolder più grande dell'utensile, il primo oggetto in collisione è il ToolHolder. Altrimenti il motore. - -- TODO Per il momento il motore ha un valore fisso: diametro di 180. Vedere se scrivere il diametro corretto in BeamData - local dDimObjToCheck = EgtIf( TOOLS[nCurrIndex].ToolHolder.dDiameter > TOOLS[nCurrIndex].dDiameter, TOOLS[nCurrIndex].ToolHolder.dDiameter, 180) + local dDimObjToCheck = EgtIf( TOOLS[nCurrIndex].ToolHolder.dDiameter > TOOLS[nCurrIndex].dDiameter, TOOLS[nCurrIndex].ToolHolder.dDiameter, BeamData.C_SIMM_ENC) local dCurrMaxMatReduction = BeamData.COLL_SIC or 5 -- calcolo riduzione per non toccare con ToolHolder / Motore @@ -117,13 +129,53 @@ function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, d end end + return ToolInfo end ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo LAMA con certe caratteristiche --- TODO da fare -function MachiningLib.FindBlade() +-- TODO da completare +function MachiningLib.FindBlade( Proc, ToolSearchParameters) + local Tool = {} + + -- parametri obbligatori + if type( ToolSearchParameters.vtToolDirection) ~= 'table' then + error( 'FindBlade : missing tool direction') + end + if type( ToolSearchParameters.bAllowTopHead) ~= 'boolean' then + error( 'FindBlade : missing top head info') + end + if type( ToolSearchParameters.bAllowBottomHead) ~= 'boolean' then + error( 'FindBlade : missing bottom head info') + end + if not ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + error( 'FindBlade : wrong head info') + end + + -- parametri opzionali + ToolSearchParameters.dElevation = ToolSearchParameters.dElevation or 0 + ToolSearchParameters.bForceLongcutBlade = ToolSearchParameters.bForceLongcutBlade or false + + local nChosenToolIndex + for i = 1, #TOOLS do + local bIsToolCompatible = true + + if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + bIsToolCompatible = TOOLS[i].bIsTopHead + elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then + bIsToolCompatible = TOOLS[i].bIsBottomHead + end + + if bIsToolCompatible then + nChosenToolIndex = i + break + end + end + + Tool = TOOLS[nChosenToolIndex] + + return Tool end ------------------------------------------------------------------------------------------------------------- diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index d130fdb..33ee616 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -15,7 +15,7 @@ -- carico librerie local BeamLib = require( 'BeamLib') local BeamData = require( 'BeamData') -local MachLib = require( 'MachiningLib') +local MachiningLib = require( 'MachiningLib') local FeatureData = require( 'FeatureData') -- Tabella per definizione modulo @@ -56,7 +56,7 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) local dElevation = Proc.MainFaces.BottomFace.dElevation -- cerco utensile - ToolInfo = MachLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, Proc.MainFaces.BottomFace.vtN) + ToolInfo = MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, Proc.MainFaces.BottomFace.vtN) if ToolInfo.idTool and TOOLS[ToolInfo.idTool].sName then if ToolInfo.dMaxMatReduction < 0 then diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua new file mode 100644 index 0000000..2675a4d --- /dev/null +++ b/Strategies/STR0003/STR0003.lua @@ -0,0 +1,757 @@ +-- Strategia: STR0003 +-- Descrizione +-- Lama + motosega per slot +-- Feature: tipo lapjoint + +-- carico librerie +local BeamLib = require( 'BeamLib') +local BeamData = require( 'BeamData') +local MachiningLib = require( 'MachiningLib') +local FeatureData = require( 'FeatureData') + +-- Tabella per definizione modulo +local STR0003 = {} +local Strategy = {} +local Blade = {} +local Chainsaw = {} + +------------------------------------------------------------------------------------------------------------- + + + +local function IsTopologyOk( Proc) + if Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' or + Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or + Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or + Proc.TopologyLongName == 'Tunnel-Through-RightAngles-Parallel-4' then + + return true + else + return false + end +end + +function GetToolFromMachining( sMachiningName) + local Tool = {} + if EgtMdbSetCurrMachining( sMachiningName) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + Tool.Name = EgtTdbGetCurrToolParam( MCH_TP.NAME) + Tool.IsCCW = ( EgtMdbGetCurrMachiningParam( MCH_MP.SPEED) < 0) + Tool.Type = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0 + -- lama + if Tool.Type == MCH_TY.SAW_STD or Tool.Type == MCH_TY.SAW_FLAT then + Tool.Thickness = EgtTdbGetCurrToolParam(MCH_TP.THICK) or 0 + Tool.MaxDepth = EgtTdbGetCurrToolMaxDepth() or 0 + Tool.SideStep = EgtTdbGetCurrToolValInNotes( MCH_TP.USERNOTES, 'SIDESTEP', 'd') + -- sega a catena + elseif Tool.Type == MCH_TY.MORTISE_STD then + Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) or 0 + Tool.MaxMat = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) or 0 + Tool.Width = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or 0 + Tool.Thickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) or 0 + Tool.CornerRadius = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) or 0 + -- altri utensili al momento non previsti + else + error( 'Wrong tool type') + end + end + end + + return Tool +end + + +function CalculateLeadInOut( Machining, EdgeToMachine) + -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) + + -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi + local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) + local dAddLengthToReduce = 0 + if bIsMortising then + dAddLengthToReduce = Machining.Tool.Diameter / 2 + else + dAddLengthToReduce = sqrt( Machining.Depth * Machining.Tool.Diameter - Machining.Depth * Machining.Depth) + end + + if Machining.Invert then + Machining.IsStartClosed, Machining.IsEndClosed = Machining.IsEndClosed, Machining.IsStartClosed + end + + local LeadIn = {} + local LeadOut = {} + LeadIn.StartAddLength = 0 + LeadOut.EndAddLength = 0 + if not bIsMortising then + LeadIn.Type = MCH_MILL_LI.LINEAR + LeadOut.Type = MCH_MILL_LI.LINEAR + LeadIn.TangentDistance = 0 + LeadOut.TangentDistance = 0 + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + LeadIn.PerpDistance = EdgeToMachine.Elevation + BeamData.CUT_SIC + LeadOut.PerpDistance = EdgeToMachine.Elevation + BeamData.CUT_SIC + else + LeadIn.PerpDistance = BeamData.CUT_SIC + LeadOut.PerpDistance = BeamData.CUT_SIC + end + LeadIn.Elevation = 0 + LeadOut.Elevation = 0 + LeadIn.CompLength = 0 + LeadOut.CompLength = 0 + if Machining.IsStartClosed and Machining.IsEndClosed then + LeadIn.StartAddLength = -dAddLengthToReduce + LeadOut.EndAddLength = -dAddLengthToReduce + elseif Machining.IsStartClosed then + LeadIn.StartAddLength = -dAddLengthToReduce + -- eventuale correzione per accorciamento maggiore di larghezza tasca + LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Length + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + elseif Machining.IsEndClosed then + LeadOut.EndAddLength = -dAddLengthToReduce + -- eventuale correzione per accorciamento maggiore di larghezza tasca + LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Length + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + else + LeadIn.StartAddLength = BeamData.CUT_EXTRA + LeadOut.EndAddLength = BeamData.CUT_EXTRA + end + else + if Machining.IsStartClosed then + LeadIn.StartAddLength = -dAddLengthToReduce + else + LeadIn.StartAddLength = BeamData.CUT_EXTRA + end + if Machining.IsEndClosed then + LeadOut.EndAddLength = -dAddLengthToReduce + else + LeadOut.EndAddLength = BeamData.CUT_EXTRA + end + end + + return LeadIn, LeadOut +end + + +function ApplyMachining( Machining, b3Raw) + local sErr = '' + local nOperationId = EgtAddMachining( Machining.OperationName, Machining.Name) + if not nOperationId then + sErr = 'Error adding machining ' .. Machining.OperationName .. '-' .. Machining.Name + EgtOutLog( sErr) + return false, sErr + end + + -- impostazione parametri lavorazione + local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) + EgtSetMachiningGeometry( Machining.Geometry) + EgtSetMachiningParam( MCH_MP.FACEUSE, Machining.Faceuse) + EgtSetMachiningParam( MCH_MP.SCC, Machining.SCC) + EgtSetMachiningParam( MCH_MP.INVERT, Machining.Invert) + EgtSetMachiningParam( MCH_MP.WORKSIDE, Machining.Workside) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, Machining.ToolInvert) + EgtSetMachiningParam( MCH_MP.OFFSR, Machining.RadialOffset) + EgtSetMachiningParam( MCH_MP.OFFSL, Machining.LongitudinalOffset) + if Machining.Type ~= MCH_OY.MORTISING then + EgtSetMachiningParam( MCH_MP.LEADINTYPE, Machining.LeadIn.Type) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, Machining.LeadOut.Type) + EgtSetMachiningParam( MCH_MP.LITANG, Machining.LeadIn.TangentDistance) + EgtSetMachiningParam( MCH_MP.LOTANG, Machining.LeadOut.TangentDistance) + EgtSetMachiningParam( MCH_MP.LIPERP, Machining.LeadIn.PerpDistance) + EgtSetMachiningParam( MCH_MP.LOPERP, Machining.LeadOut.PerpDistance) + EgtSetMachiningParam( MCH_MP.LIELEV, Machining.LeadIn.Elevation) + EgtSetMachiningParam( MCH_MP.LOELEV, Machining.LeadOut.Elevation) + EgtSetMachiningParam( MCH_MP.LICOMPLEN, Machining.LeadIn.CompLength) + EgtSetMachiningParam( MCH_MP.LOCOMPLEN, Machining.LeadOut.CompLength) + end + EgtSetMachiningParam( MCH_MP.STARTADDLEN, Machining.LeadIn.StartAddLength) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, Machining.LeadOut.EndAddLength) + if Machining.Steps then + if Machining.Steps.StepType then + EgtSetMachiningParam( MCH_MP.STEPTYPE, Machining.Steps.StepType) + end + if Machining.Steps.StepLength then + EgtSetMachiningParam( MCH_MP.STEP, Machining.Steps.StepLength) + end + end + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) + if Machining.Type == MCH_OY.MORTISING then + EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) + end + EgtSetMachiningParam( MCH_MP.OVERL, Machining.Overlap) + EgtSetMachiningParam( MCH_MP.STARTPOS, max( Machining.StartSafetyLength, EgtGetMachiningParam( MCH_MP.STARTPOS))) + if Machining.MaxElev then + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', Machining.MaxElev) + end + EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) + + local bIsApplyOk = MachiningLib.ApplyMachining( true, false) + if not bIsApplyOk then + local nErr + nErr, sErr = EgtGetLastMachMgrError() + -- se mortasatura e l'errore è compatibile (Axes values not calculable) si prova con l'altra configurazione dell'asse bloccato + -- TODO valutare se c'è modo di capire preventivamente la configurazione dell'asse bloccato e quindi rimuovere questa parte di codice + if Machining.Type == MCH_OY.MORTISING and nErr == 2507 then + if Machining.BlockedAxis.Orientation == 'perpendicular' then + Machining.BlockedAxis.Orientation = 'parallel' + else + Machining.BlockedAxis.Orientation = 'perpendicular' + end + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) + if Machining.SuggestedAngles.Index == 1 then + Machining.SuggestedAngles.Index = 2 + else + Machining.SuggestedAngles.Index = 1 + end + EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) + sErr = '' + bIsApplyOk = EgtApplyMachining( true, false) + end + if not bIsApplyOk then + nErr, sErr = EgtGetLastMachMgrError() + EgtSetOperationMode( nOperationId, false) + return false, sErr + end + end + + return true, sErr +end + + +function Blade.GetSCC( vtMachiningDirection) + -- TODO implementare SCC come per FacesBySaw + local nSCC = MCH_SCC.NONE + if AreSameVectorApprox( vtMachiningDirection, Z_AX()) then + nSCC = MCH_SCC.ADIR_ZP + elseif AreOppositeVectorApprox( vtMachiningDirection, Z_AX()) then + nSCC = MCH_SCC.ADIR_ZM + elseif AreSameVectorApprox( vtMachiningDirection, Y_AX()) then + nSCC = MCH_SCC.ADIR_YP + elseif AreOppositeVectorApprox( vtMachiningDirection, Y_AX()) then + nSCC = MCH_SCC.ADIR_YM + elseif AreSameVectorApprox( vtMachiningDirection, X_AX()) then + nSCC = MCH_SCC.ADIR_XP + elseif AreOppositeVectorApprox( vtMachiningDirection, X_AX()) then + nSCC = MCH_SCC.ADIR_XM + end + + return nSCC +end + + +function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) + local Cutting = {} + Cutting.CanApply = true + Cutting.Message = '' + Cutting.ProcId = Proc.id + + local dPocketHeight = 0 + if Proc.Topology == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + else + if FaceToMachine.Type == 'Long' then + dPocketHeight = Proc.MainFaces.BottomFace.Edges.SideEdges[1].Length + elseif FaceToMachine.Type == 'Side' then + dPocketHeight = Proc.MainFaces.BottomFace.Edges.LongEdges[1].Length + end + end + + -- ricerca utensile + local ToolSearchParameters = {} + ToolSearchParameters.dElevation = EdgeToMachine.Elevation + ToolSearchParameters.vtToolDirection = EdgeToMachine.ToolDirection + ToolSearchParameters.bAllowTopHead = true + ToolSearchParameters.bAllowBottomHead = false + ToolSearchParameters.bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade + + Cutting.Tool = MachiningLib.FindBlade( Proc, ToolSearchParameters) + if not Cutting.Name then + Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - saw blade not found' + Cutting.CanApply = false + EgtOutLog( Cutting.Message) + return Cutting + end + Cutting.Type = MCH_OY.MILLING + Cutting.Tool = GetToolFromMachining( Cutting.Name) + + -- verifica dimensioni tasca compatibili + -- se tasca meno spessa della lama la strategia non è applicabile + if Cutting.Tool.Thickness > dPocketHeight + 10 * GEO.EPS_SMALL then + Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade thickness' + Cutting.CanApply = false + EgtOutLog( Cutting.Message) + return Cutting + end + if #( Proc.MainFaces.SideFaces) > 1 then + -- se tasca più stretta della lama la strategia non è applicabile + if Cutting.Tool.Diameter > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then + Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade diameter' + Cutting.CanApply = false + EgtOutLog( Cutting.Message) + return Cutting + end + end + + -- parametri della lavorazione + -- inizio e fine aperti o chiusi + Cutting.IsStartClosed = not EdgeToMachine.IsStartOpen + Cutting.IsEndClosed = not EdgeToMachine.IsEndOpen + -- lato di lavoro e inversioni + if Cutting.Tool.IsCCW then + Cutting.Workside = MCH_MILL_WS.RIGHT + Cutting.Invert = true + else + Cutting.Workside = MCH_MILL_WS.LEFT + Cutting.Invert = false + end + if EdgeToMachine.Elevation < -10 * GEO.EPS_SMALL then + Cutting.Invert = not Cutting.Invert + end + -- TODO gestire lama da sotto e lama downUp + if FaceToMachine.VtN:getZ() < - 10 * GEO.EPS_SMALL then + Cutting.ToolInvert = true + Cutting.Invert = not Cutting.Invert + else + Cutting.ToolInvert = false + end + -- profondità e offset radiale + if Cutting.Tool.MaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + -- TODO la depth dovrebbe essere quella del machining + Cutting.Depth = abs( EdgeToMachine.Elevation) + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Cutting.RadialOffset = 0 + else + Cutting.RadialOffset = EdgeToMachine.Elevation + end + else + Cutting.Depth = Cutting.Tool.MaxDepth - 1 + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Cutting.RadialOffset = EdgeToMachine.Elevation - Cutting.Depth + else + Cutting.RadialOffset = -Cutting.Depth + end + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL and Strategy.Parameters.bApplyOnlyBlade then + Cutting.Message = 'Feature '.. Proc.idFeature .. ' : sawblade elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Cutting.Depth, 1) .. ')' + EgtOutLog( Cutting.Message) + end + end + -- step verticale e offset longitudinale + Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, Cutting.Tool.Thickness) + Cutting.Steps.StepType = MCH_MILL_ST.ONEWAY + Cutting.MaxElev = Cutting.Steps.StepLength * Cutting.Steps.Count - 10 * GEO.EPS_SMALL + if Cutting.ToolInvert and Cutting.Steps.Count > 1 then + Cutting.LongitudinalOffset = - dPocketHeight + else + Cutting.LongitudinalOffset = 0 + end + -- distanza di sicurezza + Cutting.StartSafetyLength = 10 + -- overlap + Cutting.Overlap = 0 + -- faceuse + if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then + Cutting.Faceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.ToolDirection) + else + Cutting.Faceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.ToolDirection) + end + -- SCC + Cutting.SCC = Blade.GetSCC( EdgeToMachine.ToolDirection) + -- asse bloccato + Cutting.BlockedAxis = {} + Cutting.BlockedAxis.Orientation = 'perpendicular' + Cutting.BlockedAxis.VtN = FaceToMachine.VtN + Cutting.BlockedAxis.VtOut = EgtIf( FaceToMachine.VtN:getX() > 0, X_AX(), -X_AX()) + -- approccio e retrazione + Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine) + -- eventuale step orizzontale + Cutting.HorizontalSteps = {} + if Cutting.Tool.SideStep then + Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.Depth, Cutting.Tool.SideStep) + else + Cutting.HorizontalSteps.Count = 1 + Cutting.HorizontalSteps.StepLength = 0 + end + -- geometria + Cutting.Geometry = {{Proc.id, FaceToMachine.id}} + -- nome operazione + Cutting.OperationName = 'Cut_' .. ( EgtGetName( Cutting.ProcId) or tostring( Cutting.ProcId)) .. '_' .. tostring( FaceToMachine.id + 1) + + -- eventuale avviso di danneggiamento pezzo successivo + -- TODO da sostituire con check se si riesce a separare e il grezzo dietro è lungo a sufficienza + local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.Tool.Diameter / 2 + 10 * GEO.EPS_SMALL + if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then + local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : sawblade can damage next piece.' + if #Cutting.Message > 0 then + Cutting.Message = Cutting.Message .. '\n' .. sDamageNextPieceMessage + else + Cutting.Message = sDamageNextPieceMessage + end + EgtOutLog( sDamageNextPieceMessage) + end + + return Cutting +end + + +function Blade.ApplyAllSteps( Cutting, b3Raw) + local bIsCuttingOk = false + local sCuttingApplyMessage = '' + + local dOriginalRadialOffset = Cutting.RadialOffset + local dOriginalLeadInPerpDistance = Cutting.LeadIn.PerpDistance + local dOriginalLeadOutPerpDistance = Cutting.LeadOut.PerpDistance + for i = Cutting.HorizontalSteps.Count, 1, -1 do + Cutting.RadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.StepLength * ( i - 1) + -- update distanza perpendicolare attacco per contemplare l'offset applicato + Cutting.LeadIn.PerpDistance = dOriginalLeadInPerpDistance - Cutting.RadialOffset + Cutting.LeadOut.PerpDistance = dOriginalLeadOutPerpDistance - Cutting.RadialOffset + -- applicazione lavorazione + bIsCuttingOk, sCuttingApplyMessage = ApplyMachining( Cutting, b3Raw) + -- update messaggi + if sCuttingApplyMessage and #sCuttingApplyMessage > 0 then + sCuttingApplyMessage = sCuttingApplyMessage .. 'Apply : ' .. sCuttingApplyMessage .. '\n' + end + end + + return bIsCuttingOk, sCuttingApplyMessage +end + + +function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) + local Mortising = {} + Mortising.CanApply = true + Mortising.Message = '' + Mortising.ProcId = Proc.id + local bNeedToMachineOtherSide = false + -- TODO da sostituire con flag da passare a Find che sa già il raggio + local dTestCornerRadius = 43 + -- OneSide | OneSideAndExtend | BothSides | BothSidesAndExtend + local sMortisingType + + local dPocketHeight = 0 + if Proc.Topology == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + else + if FaceToMachine.Type == 'Long' then + dPocketHeight = Proc.MainFaces.BottomFace.Edges.SideEdges[1].Length + elseif FaceToMachine.Type == 'Side' then + dPocketHeight = Proc.MainFaces.BottomFace.Edges.LongEdges[1].Length + end + end + + -- ricerca lavorazione + -- TODO da sostituire con ricerca utensile + if Proc.Topology == 'Tunnel' then + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) + sMortisingType = 'OneSideAndExtend' + if not Mortising.Name then + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) / 2 + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) + sMortisingType = 'BothSidesAndExtend' + end + elseif EdgeToMachine.Type == 'Side' and #( Proc.MainFaces.SideFaces) == 0 then + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) / 2 + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) + sMortisingType = 'BothSidesAndExtend' + else + Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation)) + sMortisingType = 'OneSide' + end + if not Mortising.Name then + Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + if sMortisingType == 'BothSidesAndExtend' then + sMortisingType = 'BothSides' + elseif sMortisingType == 'OneSideAndExtend' then + sMortisingType = 'OneSide' + end + end + if not Mortising.Name then + Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - chainsaw not found' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising, false + end + Mortising.Type = MCH_OY.MORTISING + Mortising.Tool = GetToolFromMachining( Mortising.Name) + + -- verifica dimensioni tasca compatibili + -- se tasca meno spessa della sega a catena la strategia non è applicabile + if Mortising.Tool.Thickness > dPocketHeight + 10 * GEO.EPS_SMALL then + Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw thickness' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising, false + end + if #( Proc.MainFaces.SideFaces) > 1 then + -- se tasca più stretta della sega a catena la strategia non è applicabile + if Mortising.Tool.Width > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then + Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw width' + Mortising.CanApply = false + EgtOutLog( Mortising.Message) + return Mortising, false + end + end + + -- parametri della lavorazione + -- inizio e fine aperti o chiusi + Mortising.IsStartClosed = not EdgeToMachine.IsStartOpen + Mortising.IsEndClosed = not EdgeToMachine.IsEndOpen + -- lato di lavoro e inversioni + Mortising.Invert = false + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Mortising.Workside = MCH_MILL_WS.RIGHT + Mortising.ToolInvert = false + else + Mortising.Workside = MCH_MILL_WS.LEFT + Mortising.ToolInvert = true + end + -- profondità e offset longitudinale + if sMortisingType == 'OneSide' then + Mortising.Depth = abs( EdgeToMachine.Elevation) + elseif sMortisingType == 'OneSideAndExtend' then + Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.Tool.CornerRadius + BeamData.CUT_EXTRA_MIN + elseif sMortisingType == 'BothSides' then + Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + bNeedToMachineOtherSide = true + elseif sMortisingType == 'BothSidesAndExtend' then + Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.Tool.CornerRadius + BeamData.CUT_EXTRA_MIN + bNeedToMachineOtherSide = true + end + if Mortising.Tool.MaxMat > Mortising.Depth - 10 * GEO.EPS_SMALL then + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Mortising.LongitudinalOffset = 0 + else + Mortising.LongitudinalOffset = abs( EdgeToMachine.Elevation) - Mortising.Depth + end + else + Mortising.Depth = Mortising.Tool.MaxMat - 1 + if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then + Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth + else + Mortising.LongitudinalOffset = 0 + end + Mortising.Message = 'Feature '.. Proc.idFeature .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.Depth, 1) .. ')' + EgtOutLog( Mortising.Message) + end + -- offset radiale + Mortising.RadialOffset = 0 + -- distanza di sicurezza + Mortising.StartSafetyLength = EdgeToMachine.Elevation + -- overlap + Mortising.Overlap = 0 + -- faceuse + if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then + Mortising.Faceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.ToolDirection) + else + Mortising.Faceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.ToolDirection) + end + -- SCC + Mortising.SCC = MCH_SCC.NONE + -- asse bloccato e angoli suggeriti + Mortising.BlockedAxis = {} + Mortising.BlockedAxis.Orientation = 'perpendicular' + Mortising.BlockedAxis.VtN = FaceToMachine.VtN + Mortising.SuggestedAngles = {} + Mortising.SuggestedAngles.Index = 1 + Mortising.SuggestedAngles.VtN = FaceToMachine.VtN + Mortising.SuggestedAngles.VtOrthO = EdgeToMachine.ToolDirection + -- approccio e retrazione + Mortising.LeadIn, Mortising.LeadOut = CalculateLeadInOut( Mortising, EdgeToMachine) + -- eventuale step verticale + Mortising.VerticalSteps = MachiningLib.GetMachiningSteps( dPocketHeight, Mortising.Tool.Thickness) + -- geometria + Mortising.Geometry = {{Proc.id, FaceToMachine.id}} + -- nome operazione + Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( FaceToMachine.id + 1) + + -- eventuale avviso di danneggiamento pezzo successivo + local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.Tool.Width / 2 + 10 * GEO.EPS_SMALL + if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then + local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw can damage next piece.' + if #Mortising.Message > 0 then + Mortising.Message = Mortising.Message .. '\n' .. sDamageNextPieceMessage + else + Mortising.Message = sDamageNextPieceMessage + end + EgtOutLog( sDamageNextPieceMessage) + end + + return Mortising, bNeedToMachineOtherSide +end + + +function Chainsaw.ApplyAllSteps( Mortising, b3Raw) + local bIsMortisingOk = false + local sMortisingApplyMessage = '' + + local dOriginalRadialOffsetMortising = Mortising.RadialOffset + for i = Mortising.VerticalSteps.Count, 1, -1 do + Mortising.RadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.StepLength * ( i - 1) + -- applicazione lavorazione + bIsMortisingOk, sMortisingApplyMessage = ApplyMachining( Mortising, b3Raw) + -- update messaggi + if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then + Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage + end + end + + return bIsMortisingOk, sMortisingApplyMessage +end + + +function STR0003.Make( AddMachining, Proc, Part, CustomParameters) + -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) + local StrategyLib = {} + StrategyLib.Config = require( 'STR0003\\STR0003Config') + Strategy.sName = StrategyLib.Config.sStrategyId + CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) + Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + Strategy.RatingResult = {} + + Strategy.Saw = {} + Strategy.Chainsaw = {} + + local b3Raw = EgtGetRawPartBBox( Part.idRaw) + + -- TODO per implementare la strategia con lapjoint lunghe bisogna prima riconoscere le topologie che arrivano + if Proc.IsSplittedLapJoint then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented for long lapjoint' + EgtOutLog( sErr) + return false, sErr + end + + if not IsTopologyOk( Proc) then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' + EgtOutLog( sErr) + return false, sErr + end + + -- se tasca su faccia sotto la strategia non è applicabile (la sega a catena in generale non può lavorare da sotto) + -- TODO se OnlySaw questo test è da rimuovere ma bisogna considerare anche la lama da sotto + if Proc.AffectedFaces.Bottom and ( Proc.Fct > 3 or not Proc.AffectedFaces.Top) then + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket on bottom face' + EgtOutLog( sErr) + return false, sErr + end + + -- lama + -- lavorazione di lama - fondo della tasca o fino a massimo materiale se tunnel + local Cutting = {} + if Proc.Topology == 'Tunnel' then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + else + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + end + local bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + local dBottomDepthToMachine = Cutting.RadialOffset + -- lato opposto del tunnel + if Proc.Topology == 'Tunnel' then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + else + -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato + if Cutting.RadialOffset > 10 * GEO.EPS_SMALL then + -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + end + -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + bIsCuttingOk = false + if Cutting.CanApply then + bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) + end + if not bIsCuttingOk then + return bIsCuttingOk, Cutting.Message + end + end + -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni + elseif #( Proc.MainFaces.SideFaces) == 0 then + Strategy.Parameters.bApplyOnlyBlade = true + end + end + + if Strategy.Parameters.bApplyOnlyBlade then + return bIsCuttingOk, Cutting.Message + end + + -- sega a catena + -- parametri lavorazione con sega a catena - fondo della tasca o tunnel + local Mortising = {} + local bNeedToMachineOtherSide = false + if Proc.Topology == 'Tunnel' then + Mortising, bNeedToMachineOtherSide = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + else + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + -- si lavora solo quanto non lavorato dalla lama + Mortising.MaxElev = dBottomDepthToMachine + BeamData.CUT_EXTRA + end + local bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + -- lato opposto del tunnel + if Proc.Topology == 'Tunnel' and bNeedToMachineOtherSide then + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end + else + -- se la sega a catena non è arrivata sul fondo e c'è almeno un lato aperto va lavorato + if Mortising.LongitudinalOffset > 10 * GEO.EPS_SMALL then + -- eventuale lavorazione di sega a catena - lato della tasca da cui inizia la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end + end + -- eventuale lavorazione di sega a catena - lato della tasca in cui finisce la lavorazione + if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + bIsMortisingOk = false + if Mortising.CanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + end + if not bIsMortisingOk then + return bIsMortisingOk, Mortising.Message + end + end + end + end + + local sFinalMessage = '' + if #Cutting.Message > 0 or #Mortising.Message > 0 then + sFinalMessage = Cutting.Message .. '\n' .. Mortising.Message + end + + return bIsMortisingOk, sFinalMessage +end + +------------------------------------------------------------------------------------------------------------- + + return STR0003 \ No newline at end of file diff --git a/Strategies/STR0003/STR0003Config.lua b/Strategies/STR0003/STR0003Config.lua new file mode 100644 index 0000000..879efce --- /dev/null +++ b/Strategies/STR0003/STR0003Config.lua @@ -0,0 +1,11 @@ +-- Parametri configurabili da cliente per strategia: STR0001 + +local STR0003Data = { + sStrategyId = 'STR0003', + Parameters = { + { sName = 'bApplyOnlyBlade', sValue = 'false', sDescriptionShort = 'Blade only', sDescriptionLong = 'Machining with blade only and avoid chainsaw', sType = 'b', idMessage = ''}, + { sName = 'bForceLongcutBlade', sValue = 'false', sDescriptionShort = 'Force ripping blade', sDescriptionLong = 'Force the use of ripping blade, designed for cuts parallel to the grain', sType = 'b', idMessage = ''} + } +} + +return STR0003Data \ No newline at end of file diff --git a/Strategies/Strategies.ini b/Strategies/Strategies.ini index 5e49b14..760dc45 100644 --- a/Strategies/Strategies.ini +++ b/Strategies/Strategies.ini @@ -2,6 +2,7 @@ [Comments] STR0001 = Tenone a coda di rondine. Lama + fresa a coda di rondine STR0002 = Topologia tipo LapJoint. Svuotatura con fresa +STR0003 = Topologia tipo LapJoint. Lama + motosega [Strategies] ; Processing , Gruppo , Topologia , Strategie @@ -16,29 +17,41 @@ STR0002 = Topologia tipo LapJoint. Svuotatura con fresa ; Feature : Saw Cut 13,0,Feature, ; Feature : Slot -16,0,Pocket-5-Blind,STR0002 -16,0,Groove-4-Blind,STR0002 +16,0,Pocket-5-Blind,STR0002,STR0003 +16,0,Groove-4-Blind,STR0002,STR0003 +16,0,Groove-3-Through,STR0002,STR0003 +16,0,Tunnel-4-Through,STR0003 ; Feature : Front Slot -17,0,Pocket-5-Blind,STR0002 -17,0,Groove-4-Blind,STR0002 +17,0,Pocket-5-Blind,STR0002,STR0003 +17,0,Groove-4-Blind,STR0002,STR0003 +17,0,Groove-3-Through,STR0002,STR0003 +17,0,Tunnel-4-Through,STR0003 ; Feature : Birds Mouth 20,0,Feature, ; Feature : Hip or Valley Rafter Notch 25,0,Feature, ; Feature : Ridge Lap -30,1,Pocket-5-Blind,STR0002 -30,1,Groove-4-Blind,STR0002 +30,1,Pocket-5-Blind,STR0002,STR0003 +30,1,Groove-4-Blind,STR0002,STR0003 +30,1,Groove-3-Through,STR0002,STR0003 +30,1,Tunnel-4-Through,STR0003 ; Feature : Lap Joint -30,0,Pocket-5-Blind,STR0002 -30,0,Groove-4-Blind,STR0002 +30,0,Pocket-5-Blind,STR0002,STR0003 +30,0,Groove-4-Blind,STR0002,STR0003 +30,0,Groove-3-Through,STR0002,STR0003 +30,0,Tunnel-4-Through,STR0003 ; Feature : Notch/Rabbet -32,0,Pocket-5-Blind,STR0002 -32,0,Groove-4-Blind,STR0002 +32,0,Pocket-5-Blind,STR0002,STR0003 +32,0,Groove-4-Blind,STR0002,STR0003 +32,0,Groove-3-Through,STR0002,STR0003 +32,0,Tunnel-4-Through,STR0003 ; Feature : Block Haus 33,0,Feature, ; Feature : Notch -34,0,Pocket-5-Blind,STR0002 -34,0,Groove-4-Blind,STR0002 +34,0,Pocket-5-Blind,STR0002,STR0003 +34,0,Groove-4-Blind,STR0002,STR0003 +34,0,Groove-3-Through,STR0002,STR0003 +34,0,Tunnel-4-Through,STR0003 ; Feature : French Ridge Lap 35,1,Feature, ; Feature : Chamfer @@ -48,8 +61,10 @@ STR0002 = Topologia tipo LapJoint. Svuotatura con fresa ; Feature : Block Haus Front 38,0,Feature, ; Feature : Pocket -39,0,Pocket-5-Blind,STR0002 -39,0,Groove-4-Blind,STR0002 +39,0,Pocket-5-Blind,STR0002,STR0003 +39,0,Groove-4-Blind,STR0002,STR0003 +39,0,Groove-3-Through,STR0002,STR0003 +39,0,Tunnel-4-Through,STR0003 ; Feature : Drilling 40,0,Feature, ; Feature : Tenon From 297dcba66b208c534223c9621b03ff3ee8a92d88 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Mon, 20 May 2024 18:44:11 +0200 Subject: [PATCH 2/5] - in STR0003_BladePlusChainsaw modifiche parziali per adattarla all' automatismo - in MachiningLib aggiunta FindChainsaw e varie modifiche - altre modifiche minori --- LuaLibs/BeamExec.lua | 14 ++- LuaLibs/MachiningLib.lua | 174 ++++++++++++++++++++++++--------- Strategies/STR0002/STR0002.lua | 12 +-- Strategies/STR0003/STR0003.lua | 115 ++++++++++++---------- 4 files changed, 209 insertions(+), 106 deletions(-) diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index 544a4d5..c262acd 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -68,8 +68,12 @@ local function IsToolOk( Tool) if Tool.sFamily == 'DRILLBIT' then return true -- altrimenti controllo dati aggiuntivi altre famiglie di utensili + elseif Tool.sFamily == 'MORTISE' then + if Tool.dCornerRadius then + return true + end else - if Tool.dThick then + if Tool.dThickness then return true end end @@ -128,7 +132,7 @@ function BeamExec.GetToolsFromDB() -- lettura parametri non comuni ( famiglia DRILLBIT non ha parametri specifici) if sToolFamily ~= 'DRILLBIT' then - Tool.dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) + Tool.dThickness = EgtTdbGetCurrToolParam( MCH_TP.THICK) Tool.dLongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET) Tool.dRadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET) -- recupero parametri propri delle frese @@ -146,7 +150,7 @@ function BeamExec.GetToolsFromDB() -- recupero parametri propri delle lame elseif sToolFamily == 'SAWBLADE' then Tool.bIsUsedForLongCut = EgtGetValInNotes( Tool.sUserNotes, 'LONGCUT') == 1 or false -- false coem valore di default - Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or Tool.dThick -- se non settato nell'utensile, considero lo spessore lama + Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or Tool.dThickness -- se non settato nell'utensile, considero lo spessore lama Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dDiameter / 4) -- se non settato nell'utensile, considero un quarto del diametro -- recupero parametri propri delle motoseghe elseif sToolFamily == 'MORTISE' then @@ -154,7 +158,9 @@ function BeamExec.GetToolsFromDB() Tool.bIsMortise = EgtGetValInNotes( Tool.sUserNotes, 'MORTISE') == 1 Tool.bIsChainSaw = not Tool.bIsMortise Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or floor( Tool.dMaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza - Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or ( Tool.dThick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza + Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or ( Tool.dThickness - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza + Tool.dCornerRadius = EgtTdbGetCurrToolParam( MCH_TP.CORNRAD) + Tool.dWidth = Tool.dDiameter end end diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 449b305..95495b0 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -14,11 +14,10 @@ local BeamData = require( 'BeamData') EgtOutLog( ' MachiningLib started', 1) --------------------------------------------------------------------- ---- ----@param Proc table la feature ----@param vtTool Vector3d il vettore direzione utensile ----@return number dAngle angolo tra la faccia d'ingresso e la direzione utensile +-- TODO da considerare solo angolo 2D?? local function GetToolEntryAngle( Proc, vtTool) + local Angle = {} + local dSinAngle = -10 * GEO.EPS_SMALL local vtNorm if Proc.AffectedFaces.bTop then @@ -48,9 +47,17 @@ local function GetToolEntryAngle( Proc, vtTool) local dCosAngle = sqrt( 1 - sqr( dSinAngle)) local dAngle = acos( dCosAngle) + local dTanAngle + if dAngle ~= 0 and dAngle ~= 90 then + dTanAngle = sqrt( 1 - dCosAngle * dCosAngle) / dCosAngle + end - return dAngle + Angle.dValue = dAngle + Angle.dSin = dSinAngle + Angle.dCos = dCosAngle + Angle.dTan = dTanAngle + return Angle end ------------------------------------------------------------------------------------------------------------- @@ -71,65 +78,72 @@ end function MachiningLib.FindMill( Proc, ToolSearchParameters) local ToolInfo = {} - for nCurrIndex=1, #TOOLS do + local nBestToolIndex + local dBestToolResidualDepth = 0 + for i = 1, #TOOLS do -- prima verifico che utensile sia compatibile - local bCompatibleTool = true - if TOOLS[nCurrIndex].sType ~= ToolSearchParameters.sType then - bCompatibleTool = false - elseif TOOLS[nCurrIndex].dDiameter > ToolSearchParameters.dMaxToolDiameter then - bCompatibleTool = false - elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[nCurrIndex].dSideAngle ~= 0 or TOOLS[nCurrIndex].bIsPen) then - bCompatibleTool = false - elseif ToolSearchParameters.sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then - bCompatibleTool = false - elseif ToolSearchParameters.sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then - bCompatibleTool = false - elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[nCurrIndex].bIsPen then - bCompatibleTool = false + local bIsToolCompatible = true + if TOOLS[i].sType ~= ToolSearchParameters.sType then + bIsToolCompatible = false + elseif TOOLS[i].dDiameter > ToolSearchParameters.dMaxToolDiameter then + bIsToolCompatible = false + elseif ToolSearchParameters.sMillShape == 'STANDARD' and ( TOOLS[i].dSideAngle ~= 0 or TOOLS[i].bIsPen) then + bIsToolCompatible = false + elseif ToolSearchParameters.sMillShape == 'DOVETAIL' and not TOOLS[i].bIsDoveTail then + bIsToolCompatible = false + elseif ToolSearchParameters.sMillShape == 'TSHAPEMILL' and not TOOLS[i].bIsTMill then + bIsToolCompatible = false + elseif ToolSearchParameters.sMillShape == 'PEN' and not TOOLS[i].bIsPen then + bIsToolCompatible = false -- TODO controllare montaggio e verificare se direzione utensile raggiungibile. Serve funzione in BeamData end -- scelgo il migliore - if bCompatibleTool then + if bIsToolCompatible then -- calcolo riduzione del massimo materiale utilizzabile - local dToolEntryAngle = GetToolEntryAngle( Proc, ToolSearchParameters.vtToolDir) + local ToolEntryAngle = GetToolEntryAngle( Proc, ToolSearchParameters.vtToolDir) -- se ToolHolder più grande dell'utensile, il primo oggetto in collisione è il ToolHolder. Altrimenti il motore. - local dDimObjToCheck = EgtIf( TOOLS[nCurrIndex].ToolHolder.dDiameter > TOOLS[nCurrIndex].dDiameter, TOOLS[nCurrIndex].ToolHolder.dDiameter, BeamData.C_SIMM_ENC) - local dCurrMaxMatReduction = BeamData.COLL_SIC or 5 + local dDimObjToCheck = EgtIf( TOOLS[i].ToolHolder.dDiameter > TOOLS[i].dDiameter, TOOLS[i].ToolHolder.dDiameter, BeamData.C_SIMM_ENC) + local dCurrentMaxMatReduction = BeamData.COLL_SIC or 5 + -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) + -- TODO considerare anche il caso in cui lo stelo sia più grande del diametro utensile + -- TODO nei confronti tra valori gestire tolleranze -- calcolo riduzione per non toccare con ToolHolder / Motore - if dToolEntryAngle > 0 and dToolEntryAngle < 90 then - dCurrMaxMatReduction = dCurrMaxMatReduction / cos( 90 - dToolEntryAngle) + ( ( dDimObjToCheck - TOOLS[nCurrIndex].dDiameter) / 2) / tan( dToolEntryAngle) + if ToolEntryAngle.dValue > 0 and ToolEntryAngle.dValue < 90 then + dCurrentMaxMatReduction = dCurrentMaxMatReduction / ToolEntryAngle.dSin + ( ( dDimObjToCheck - TOOLS[i].dDiameter) / 2) / ToolEntryAngle.dTan end -- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili - local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - ToolSearchParameters.dElevation - dCurrMaxMatReduction + local dCurrentResidualDepth = ToolSearchParameters.dElevation + dCurrentMaxMatReduction - TOOLS[i].dMaxDepth -- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore - if not ToolInfo.nToolIndex or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then - ToolInfo.nToolIndex = nCurrIndex - ToolInfo.dMaxMatReduction = dCurrMachReduction + if not nBestToolIndex or ( dBestToolResidualDepth > 0 and dCurrentResidualDepth <= 0) then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth -- altrimenti scelgo il migliore else -- se entrambi completi - if ToolInfo.dMaxMatReduction > 0 and dCurrMachReduction > 0 then + if dBestToolResidualDepth <= 0 and dCurrentResidualDepth <= 0 then -- scelgo utensile con rapporto lunghezza / diametro minore - if ( TOOLS[nCurrIndex].dLength / pow( TOOLS[nCurrIndex].dDiameter, 1.5)) < ( TOOLS[ToolInfo.nToolIndex].dLength / pow( TOOLS[ToolInfo.nToolIndex].dDiameter, 1.5)) then - ToolInfo.nToolIndex = nCurrIndex - ToolInfo.dMaxMatReduction = dCurrMachReduction + if ( TOOLS[i].dLength / pow( TOOLS[i].dDiameter, 1.5)) < ( TOOLS[nBestToolIndex].dLength / pow( TOOLS[nBestToolIndex].dDiameter, 1.5)) then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth end -- se entrambi incompleti - elseif ToolInfo.dMaxMatReduction < 0 and dCurrMachReduction < 0 then + elseif dBestToolResidualDepth > 0 and dCurrentResidualDepth > 0 then --scelgo quello che lavora di più - if dCurrMachReduction > ToolInfo.dMaxMatReduction then - ToolInfo.nToolIndex = nCurrIndex - ToolInfo.dMaxMatReduction = dCurrMachReduction + if dCurrentResidualDepth > dBestToolResidualDepth then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth end end end end - end + ToolInfo.nToolIndex = nBestToolIndex + ToolInfo.dResidualDepth = dBestToolResidualDepth + return ToolInfo end @@ -137,7 +151,7 @@ end -- funzione per cercare utensile tipo LAMA con certe caratteristiche -- TODO da completare function MachiningLib.FindBlade( Proc, ToolSearchParameters) - local Tool = {} + local ToolInfo = {} -- parametri obbligatori if type( ToolSearchParameters.vtToolDirection) ~= 'table' then @@ -157,7 +171,7 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) ToolSearchParameters.dElevation = ToolSearchParameters.dElevation or 0 ToolSearchParameters.bForceLongcutBlade = ToolSearchParameters.bForceLongcutBlade or false - local nChosenToolIndex + local nBestToolIndex for i = 1, #TOOLS do local bIsToolCompatible = true @@ -168,14 +182,14 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) end if bIsToolCompatible then - nChosenToolIndex = i + nBestToolIndex = i break end end - Tool = TOOLS[nChosenToolIndex] + ToolInfo.nToolIndex = nBestToolIndex - return Tool + return ToolInfo end ------------------------------------------------------------------------------------------------------------- @@ -185,9 +199,77 @@ function MachiningLib.FindDrill() end ------------------------------------------------------------------------------------------------------------- --- funzione per cercare utensile tipo PUNTA A FORARE con certe caratteristiche --- TODO da fare -function MachiningLib.FindChainSaw() +-- funzione per cercare utensile tipo SEGA A CATENA con certe caratteristiche +-- TODO da completare +-- TODO implementare sorting in base a sSortingCriterion +function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) + local ToolInfo = {} + + -- parametri obbligatori + if type( ToolSearchParameters.vtToolDirection) ~= 'table' then + error( 'FindBlade : missing tool direction') + end + if type( ToolSearchParameters.bAllowTopHead) ~= 'boolean' then + error( 'FindBlade : missing top head info') + end + if type( ToolSearchParameters.bAllowBottomHead) ~= 'boolean' then + error( 'FindBlade : missing bottom head info') + end + if not ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + error( 'FindBlade : wrong head info') + end + + -- parametri opzionali + ToolSearchParameters.dElevation = ToolSearchParameters.dElevation or 0 + ToolSearchParameters.bExtendWithCornerRadius = ToolSearchParameters.bExtendWithCornerRadius or false + ToolSearchParameters.sSortingCriterion = ToolSearchParameters.sSortingCriterion or 'Standard' + + local nBestToolIndex + local dBestToolResidualDepth = 0 + for i = 1, #TOOLS do + local bIsToolCompatible = true + + if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + bIsToolCompatible = TOOLS[i].bIsTopHead + elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then + bIsToolCompatible = TOOLS[i].bIsBottomHead + end + + -- TODO nei confronti tra valori gestire tolleranze + if bIsToolCompatible then + if ToolSearchParameters.dElevation > 10 * GEO.EPS_SMALL and ToolSearchParameters.bExtendWithCornerRadius then + ToolSearchParameters.dElevation = ToolSearchParameters.dElevation + TOOLS[i].dCornerRadius + end + -- TODO gestire accorciamento massimo materiale per inclinazione + local dCurrentResidualDepth = ToolSearchParameters.dElevation - TOOLS[i].dMaxDepth + -- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore + if not nBestToolIndex or ( dBestToolResidualDepth > 0 and dCurrentResidualDepth <= 0) then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth + -- altrimenti scelgo il migliore + else + -- se entrambi completi + if dBestToolResidualDepth <= 0 and dCurrentResidualDepth <= 0 then + -- scelgo utensile con rapporto lunghezza / diametro minore + if ( TOOLS[i].dLength / pow( TOOLS[i].dDiameter, 1.5)) < ( TOOLS[nBestToolIndex].dLength / pow( TOOLS[nBestToolIndex].dDiameter, 1.5)) then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth + end + -- se entrambi incompleti + elseif dBestToolResidualDepth > 0 and dCurrentResidualDepth > 0 then + --scelgo quello che lavora di più + if dCurrentResidualDepth > dBestToolResidualDepth then + nBestToolIndex = i + dBestToolResidualDepth = dCurrentResidualDepth + end + end + end + end + end + + ToolInfo.nToolIndex = nBestToolIndex + + return ToolInfo end ------------------------------------------------------------------------------------------------------------- diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index 4fd7db4..38f33bf 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -32,7 +32,7 @@ local function IsTopologyOk( Proc) end ------------------------------------------------------------------------------------------------------------- -function STR0002.Make( AddMachining, Proc, Part, CustomParameters) +function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri de default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0002\\STR0002Config') @@ -61,17 +61,17 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) ToolInfo = MachiningLib.FindMill( Proc, ToolSearchParameters) if ToolInfo.nToolIndex and TOOLS[ToolInfo.nToolIndex].sName then - if ToolInfo.dMaxMatReduction < 0 then + if ToolInfo.dResidualDepth > 0 then Strategy.RatingResult.sStatus = 'Not-Completed' else Strategy.RatingResult.sStatus = 'Completed' end - Strategy.RatingResult.dCompletionIndex = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation + ToolInfo.dMaxMatReduction) / Proc.MainFaces.BottomFace.dElevation) * 100) + Strategy.RatingResult.dCompletionIndex = min( 100, ( ( Proc.MainFaces.BottomFace.dElevation - ToolInfo.dResidualDepth) / Proc.MainFaces.BottomFace.dElevation) * 100) Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'Mill', Strategy.RatingResult.dCompletionIndex) Strategy.RatingResult.sInfo = '' -- se richiesto applico lavorazione - if AddMachining then + if bAddMachining then -- TODO gestione spezzatura da completare -- le lunghezza richiede spezzatura if ( Proc.b3Box:getDimX() > BeamData.LONGCUT_MAXLEN) or ( Proc.b3Box:getDimX() > 0.7 * Part.b3Solid:getDimX() and Proc.b3Box:getDimX() > BeamData.LONGCUT_ENDLEN) then @@ -143,7 +143,7 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) for i = 1, #vAddId do EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName) EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep) - EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction)) + EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, -ToolInfo.dResidualDepth)) EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep) EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG) @@ -162,7 +162,7 @@ function STR0002.Make( AddMachining, Proc, Part, CustomParameters) else EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.nToolIndex].sName) EgtSetMachiningParam( MCH_MP.STEP, TOOLS[ToolInfo.nToolIndex].dStep) - EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, ToolInfo.dMaxMatReduction)) + EgtSetMachiningParam( MCH_MP.DEPTH, min( 0, -ToolInfo.dResidualDepth)) EgtSetMachiningParam( MCH_MP.SIDESTEP, TOOLS[ToolInfo.nToolIndex].dSideStep) EgtSetMachiningParam( MCH_MP.SUBTYPE, MCH_POCK_SUB.SPIRALOUT) EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_POCK_LI.ZIGZAG) diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua index 2675a4d..608a126 100644 --- a/Strategies/STR0003/STR0003.lua +++ b/Strategies/STR0003/STR0003.lua @@ -63,7 +63,7 @@ function GetToolFromMachining( sMachiningName) end -function CalculateLeadInOut( Machining, EdgeToMachine) +local function CalculateLeadInOut( Machining, EdgeToMachine) -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi @@ -131,7 +131,7 @@ function CalculateLeadInOut( Machining, EdgeToMachine) end -function ApplyMachining( Machining, b3Raw) +local function AddNewMachining( Machining, b3Raw) local sErr = '' local nOperationId = EgtAddMachining( Machining.OperationName, Machining.Name) if not nOperationId then @@ -256,25 +256,28 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) -- ricerca utensile local ToolSearchParameters = {} - ToolSearchParameters.dElevation = EdgeToMachine.Elevation + ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) ToolSearchParameters.vtToolDirection = EdgeToMachine.ToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = false ToolSearchParameters.bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade - - Cutting.Tool = MachiningLib.FindBlade( Proc, ToolSearchParameters) + local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + if not ToolInfo.nToolIndex then + ToolSearchParameters.dElevation = 0 + ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) + end if not Cutting.Name then Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - saw blade not found' Cutting.CanApply = false EgtOutLog( Cutting.Message) return Cutting end + Cutting.nToolIndex = ToolInfo.nToolIndex Cutting.Type = MCH_OY.MILLING - Cutting.Tool = GetToolFromMachining( Cutting.Name) -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile - if Cutting.Tool.Thickness > dPocketHeight + 10 * GEO.EPS_SMALL then + if Cutting.TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade thickness' Cutting.CanApply = false EgtOutLog( Cutting.Message) @@ -282,7 +285,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile - if Cutting.Tool.Diameter > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then + if Cutting.TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade diameter' Cutting.CanApply = false EgtOutLog( Cutting.Message) @@ -295,7 +298,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.IsStartClosed = not EdgeToMachine.IsStartOpen Cutting.IsEndClosed = not EdgeToMachine.IsEndOpen -- lato di lavoro e inversioni - if Cutting.Tool.IsCCW then + if Cutting.TOOLS[Cutting.nToolIndex].bIsCCW then Cutting.Workside = MCH_MILL_WS.RIGHT Cutting.Invert = true else @@ -313,7 +316,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.ToolInvert = false end -- profondità e offset radiale - if Cutting.Tool.MaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + if Cutting.TOOLS[Cutting.nToolIndex].dMaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then -- TODO la depth dovrebbe essere quella del machining Cutting.Depth = abs( EdgeToMachine.Elevation) if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then @@ -322,7 +325,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.RadialOffset = EdgeToMachine.Elevation end else - Cutting.Depth = Cutting.Tool.MaxDepth - 1 + Cutting.Depth = Cutting.TOOLS[Cutting.nToolIndex].MaxDepth - 1 if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Cutting.RadialOffset = EdgeToMachine.Elevation - Cutting.Depth else @@ -334,7 +337,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) end end -- step verticale e offset longitudinale - Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, Cutting.Tool.Thickness) + Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, Cutting.TOOLS[Cutting.nToolIndex].dThickness) Cutting.Steps.StepType = MCH_MILL_ST.ONEWAY Cutting.MaxElev = Cutting.Steps.StepLength * Cutting.Steps.Count - 10 * GEO.EPS_SMALL if Cutting.ToolInvert and Cutting.Steps.Count > 1 then @@ -363,8 +366,8 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine) -- eventuale step orizzontale Cutting.HorizontalSteps = {} - if Cutting.Tool.SideStep then - Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.Depth, Cutting.Tool.SideStep) + if Cutting.TOOLS[Cutting.nToolIndex].dSideStep then + Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.Depth, Cutting.TOOLS[Cutting.nToolIndex].dSideStep) else Cutting.HorizontalSteps.Count = 1 Cutting.HorizontalSteps.StepLength = 0 @@ -376,7 +379,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) -- eventuale avviso di danneggiamento pezzo successivo -- TODO da sostituire con check se si riesce a separare e il grezzo dietro è lungo a sufficienza - local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.Tool.Diameter / 2 + 10 * GEO.EPS_SMALL + local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.TOOLS[Cutting.nToolIndex].dDiameter / 2 + 10 * GEO.EPS_SMALL if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : sawblade can damage next piece.' if #Cutting.Message > 0 then @@ -391,7 +394,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) end -function Blade.ApplyAllSteps( Cutting, b3Raw) +function Blade.AddMachiningAllSteps( Cutting, b3Raw) local bIsCuttingOk = false local sCuttingApplyMessage = '' @@ -404,7 +407,7 @@ function Blade.ApplyAllSteps( Cutting, b3Raw) Cutting.LeadIn.PerpDistance = dOriginalLeadInPerpDistance - Cutting.RadialOffset Cutting.LeadOut.PerpDistance = dOriginalLeadOutPerpDistance - Cutting.RadialOffset -- applicazione lavorazione - bIsCuttingOk, sCuttingApplyMessage = ApplyMachining( Cutting, b3Raw) + bIsCuttingOk, sCuttingApplyMessage = AddNewMachining( Cutting, b3Raw) -- update messaggi if sCuttingApplyMessage and #sCuttingApplyMessage > 0 then sCuttingApplyMessage = sCuttingApplyMessage .. 'Apply : ' .. sCuttingApplyMessage .. '\n' @@ -421,8 +424,6 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.Message = '' Mortising.ProcId = Proc.id local bNeedToMachineOtherSide = false - -- TODO da sostituire con flag da passare a Find che sa già il raggio - local dTestCornerRadius = 43 -- OneSide | OneSideAndExtend | BothSides | BothSidesAndExtend local sMortisingType @@ -437,42 +438,56 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end end - -- ricerca lavorazione - -- TODO da sostituire con ricerca utensile + -- ricerca utensile + local ToolSearchParameters = {} + local ToolInfo = {} + ToolSearchParameters.vtToolDirection = EdgeToMachine.ToolDirection + ToolSearchParameters.bAllowTopHead = true + ToolSearchParameters.bAllowBottomHead = false if Proc.Topology == 'Tunnel' then - Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) sMortisingType = 'OneSideAndExtend' - if not Mortising.Name then - Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) / 2 + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) + ToolSearchParameters.bExtendWithCornerRadius = true + ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) + BeamData.CUT_EXTRA + ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) + if not TOOLS[ToolInfo.nToolIndex].sName then sMortisingType = 'BothSidesAndExtend' + ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) / 2 + BeamData.CUT_EXTRA_MIN + ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end elseif EdgeToMachine.Type == 'Side' and #( Proc.MainFaces.SideFaces) == 0 then - Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation) / 2 + dTestCornerRadius + BeamData.CUT_EXTRA_MIN) sMortisingType = 'BothSidesAndExtend' + ToolSearchParameters.bExtendWithCornerRadius = true + ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) / 2 + BeamData.CUT_EXTRA_MIN + ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) else - Mortising.Name = ML.FindSawing( 'Sawing', abs( EdgeToMachine.Elevation)) sMortisingType = 'OneSide' + ToolSearchParameters.bExtendWithCornerRadius = false + ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) + BeamData.CUT_EXTRA + ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end - if not Mortising.Name then - Mortising.Name = ML.FindSawing( 'Sawing', nil, nil, 'Longest') + if not TOOLS[ToolInfo.nToolIndex].sName then if sMortisingType == 'BothSidesAndExtend' then sMortisingType = 'BothSides' elseif sMortisingType == 'OneSideAndExtend' then sMortisingType = 'OneSide' end + ToolSearchParameters.bExtendWithCornerRadius = false + ToolSearchParameters.dElevation = nil + ToolSearchParameters.sSortingCriterion = 'Longest' + ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end - if not Mortising.Name then + if not TOOLS[ToolInfo.nToolIndex].sName then Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - chainsaw not found' Mortising.CanApply = false EgtOutLog( Mortising.Message) return Mortising, false end + Mortising.nToolIndex = ToolInfo.nToolIndex Mortising.Type = MCH_OY.MORTISING - Mortising.Tool = GetToolFromMachining( Mortising.Name) -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if Mortising.Tool.Thickness > dPocketHeight + 10 * GEO.EPS_SMALL then + if Mortising.TOOLS[Mortising.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw thickness' Mortising.CanApply = false EgtOutLog( Mortising.Message) @@ -480,7 +495,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile - if Mortising.Tool.Width > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then + if Mortising.TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw width' Mortising.CanApply = false EgtOutLog( Mortising.Message) @@ -505,22 +520,22 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi if sMortisingType == 'OneSide' then Mortising.Depth = abs( EdgeToMachine.Elevation) elseif sMortisingType == 'OneSideAndExtend' then - Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.Tool.CornerRadius + BeamData.CUT_EXTRA_MIN + Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN elseif sMortisingType == 'BothSides' then Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 bNeedToMachineOtherSide = true elseif sMortisingType == 'BothSidesAndExtend' then - Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.Tool.CornerRadius + BeamData.CUT_EXTRA_MIN + Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN bNeedToMachineOtherSide = true end - if Mortising.Tool.MaxMat > Mortising.Depth - 10 * GEO.EPS_SMALL then + if Mortising.TOOLS[Mortising.nToolIndex].dMaxMat > Mortising.Depth - 10 * GEO.EPS_SMALL then if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.LongitudinalOffset = 0 else Mortising.LongitudinalOffset = abs( EdgeToMachine.Elevation) - Mortising.Depth end else - Mortising.Depth = Mortising.Tool.MaxMat - 1 + Mortising.Depth = Mortising.TOOLS[Mortising.nToolIndex].dMaxMat - 1 if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth else @@ -554,14 +569,14 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi -- approccio e retrazione Mortising.LeadIn, Mortising.LeadOut = CalculateLeadInOut( Mortising, EdgeToMachine) -- eventuale step verticale - Mortising.VerticalSteps = MachiningLib.GetMachiningSteps( dPocketHeight, Mortising.Tool.Thickness) + Mortising.VerticalSteps = MachiningLib.GetMachiningSteps( dPocketHeight, Mortising.TOOLS[Mortising.nToolIndex].dThickness) -- geometria Mortising.Geometry = {{Proc.id, FaceToMachine.id}} -- nome operazione Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( FaceToMachine.id + 1) -- eventuale avviso di danneggiamento pezzo successivo - local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.Tool.Width / 2 + 10 * GEO.EPS_SMALL + local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.TOOLS[Mortising.nToolIndex].dWidth / 2 + 10 * GEO.EPS_SMALL if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw can damage next piece.' if #Mortising.Message > 0 then @@ -576,7 +591,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end -function Chainsaw.ApplyAllSteps( Mortising, b3Raw) +function Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) local bIsMortisingOk = false local sMortisingApplyMessage = '' @@ -584,7 +599,7 @@ function Chainsaw.ApplyAllSteps( Mortising, b3Raw) for i = Mortising.VerticalSteps.Count, 1, -1 do Mortising.RadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.StepLength * ( i - 1) -- applicazione lavorazione - bIsMortisingOk, sMortisingApplyMessage = ApplyMachining( Mortising, b3Raw) + bIsMortisingOk, sMortisingApplyMessage = AddNewMachining( Mortising, b3Raw) -- update messaggi if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage @@ -595,7 +610,7 @@ function Chainsaw.ApplyAllSteps( Mortising, b3Raw) end -function STR0003.Make( AddMachining, Proc, Part, CustomParameters) +function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti) local StrategyLib = {} StrategyLib.Config = require( 'STR0003\\STR0003Config') @@ -609,7 +624,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) local b3Raw = EgtGetRawPartBBox( Part.idRaw) - -- TODO per implementare la strategia con lapjoint lunghe bisogna prima riconoscere le topologie che arrivano + -- TODO implementare gestione lapjoint lunghe if Proc.IsSplittedLapJoint then local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented for long lapjoint' EgtOutLog( sErr) @@ -639,7 +654,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) end local bIsCuttingOk = false - if Cutting.CanApply then + if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) end if not bIsCuttingOk then @@ -650,7 +665,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) if Proc.Topology == 'Tunnel' then Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) bIsCuttingOk = false - if Cutting.CanApply then + if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) end if not bIsCuttingOk then @@ -663,7 +678,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) bIsCuttingOk = false - if Cutting.CanApply then + if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) end if not bIsCuttingOk then @@ -674,7 +689,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) bIsCuttingOk = false - if Cutting.CanApply then + if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) end if not bIsCuttingOk then @@ -703,14 +718,14 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) Mortising.MaxElev = dBottomDepthToMachine + BeamData.CUT_EXTRA end local bIsMortisingOk = false - if Mortising.CanApply then + if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) end -- lato opposto del tunnel if Proc.Topology == 'Tunnel' and bNeedToMachineOtherSide then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) bIsMortisingOk = false - if Mortising.CanApply then + if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then @@ -723,7 +738,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) bIsMortisingOk = false - if Mortising.CanApply then + if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then @@ -734,7 +749,7 @@ function STR0003.Make( AddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) bIsMortisingOk = false - if Mortising.CanApply then + if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then From 8cff8827a0066144a10b0b82f7b01c4da81139b1 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Wed, 22 May 2024 16:59:06 +0200 Subject: [PATCH 3/5] - in FaceData GetSideFaces allineata alle altre e piccole modifiche a GetLongFaces - in BeamLib riportata la funzione GetNearestOrthoOpposite da automatismo vecchio - in MachiningLib piccole modifiche - in STR0003 corpose modifiche, in particolare allineamento con standard nomenclatura --- LuaLibs/BeamLib.lua | 35 +++ LuaLibs/FaceData.lua | 66 ++--- LuaLibs/MachiningLib.lua | 23 +- Strategies/STR0003/STR0003.lua | 460 ++++++++++++++++----------------- 4 files changed, 301 insertions(+), 283 deletions(-) diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 485aa67..82e8c20 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -175,6 +175,41 @@ function BeamLib.GetAffectedFaces( Proc) return vtFacesAffected end +--------------------------------------------------------------------- +function BeamLib.GetNearestOrthoOpposite( vtRef, vtNorm) + -- se definita anche la normale alla faccia, elimino la parte di vtRef parallela a questa + local vtMyRef = Vector3d( vtRef) + if vtNorm then + vtMyRef = vtMyRef - ( vtMyRef * vtNorm) * vtNorm + vtMyRef:normalize() + end + -- se prevalente una componente orizzontale (con piccolissimo vantaggio) + if abs( vtMyRef:getX()) > 0.91 * abs( vtMyRef:getZ()) or abs( vtMyRef:getY()) > 0.91 * abs( vtMyRef:getZ()) then + -- se prevale la componente destra/sinistra + if abs( vtMyRef:getX()) > 0.95 * abs( vtMyRef:getY()) then + if vtMyRef:getX() > -GEO.EPS_SMALL then + return MCH_MILL_FU.ORTHO_LEFT + else + return MCH_MILL_FU.ORTHO_RIGHT + end + else + if vtMyRef:getY() > -GEO.EPS_SMALL then + return MCH_MILL_FU.ORTHO_FRONT + else + return MCH_MILL_FU.ORTHO_BACK + end + end + -- altrimenti prevale la verticale + else + if vtMyRef:getZ() > -GEO.EPS_SMALL then + return MCH_MILL_FU.ORTHO_DOWN + else + return MCH_MILL_FU.ORTHO_TOP + end + end + return nil +end + --------------------------------------------------------------------- -- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce function BeamLib.Is3EdgesApprox( Proc, idFace, nAddGrpId) diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index a7af641..b21b029 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -293,8 +293,8 @@ local function GetLongFaces( Proc, MainFaces) local BottomFace = MainFaces.BottomFace or GetBottomFace( Proc) - local nFirstLongFaceId = GDB_ID.NULL - local nSecondLongFaceId = GDB_ID.NULL + local idFirstLongFace = GDB_ID.NULL + local idSecondLongFace = GDB_ID.NULL if not BottomFace then local FacesSortedByGreatestArea = {} for i = 1, Proc.nFct do @@ -303,22 +303,22 @@ local function GetLongFaces( Proc, MainFaces) FacesSortedByGreatestArea[i].dArea = Proc.Faces[i].dArea end table.sort( FacesSortedByGreatestArea, function (a, b) return a.dArea > b.dArea end) - nFirstLongFaceId = FacesSortedByGreatestArea[1].id - local FacesNotAdjacent = GetNotAdjacentFaces( Proc, nFirstLongFaceId) - nSecondLongFaceId = FacesNotAdjacent[1].id + idFirstLongFace = FacesSortedByGreatestArea[1].id + local FacesNotAdjacent = GetNotAdjacentFaces( Proc, idFirstLongFace) + idSecondLongFace = FacesNotAdjacent[1].id else if not BottomFace.MainEdges.LongEdges[1].bIsOpen then - nFirstLongFaceId = BottomFace.MainEdges.LongEdges[1].idAdjacentFace + idFirstLongFace = BottomFace.MainEdges.LongEdges[1].idAdjacentFace end if not BottomFace.MainEdges.LongEdges[2].bIsOpen then - nSecondLongFaceId = BottomFace.MainEdges.LongEdges[2].idAdjacentFace + idSecondLongFace = BottomFace.MainEdges.LongEdges[2].idAdjacentFace end end - if nFirstLongFaceId > -1 then - LongFaces[1] = Proc.Faces[nFirstLongFaceId + 1] + if idFirstLongFace > -1 then + table.insert( LongFaces, Proc.Faces[idFirstLongFace + 1]) end - if nSecondLongFaceId > -1 then - LongFaces[2] = Proc.Faces[nSecondLongFaceId + 1] + if idSecondLongFace > -1 then + table.insert( LongFaces, Proc.Faces[idSecondLongFace + 1]) end for i = 1, #LongFaces do @@ -381,39 +381,23 @@ local function GetSideFaces( Proc, MainFaces) error( 'GetSideFaces : Topology not implemented') end - -- TODO da sistemare come Bottom e Long + local LongFaces = MainFaces.LongFaces or GetLongFaces( Proc, MainFaces) - local idBottomFace = GDB_ID.NULL - if Proc.Topology.sFamily ~= 'Tunnel' then - if MainFaces.BottomFace then - idBottomFace = MainFaces.BottomFace.id - else - local BottomFace = GetBottomFace( Proc) - idBottomFace = BottomFace.id or idBottomFace - end + local idFirstSideFace = GDB_ID.NULL + local idSecondSideFace = GDB_ID.NULL + if not LongFaces[1].MainEdges.SideEdges[1].bIsOpen then + idFirstSideFace = LongFaces[1].MainEdges.SideEdges[1].idAdjacentFace end - - local LongFaces = {} - if MainFaces.LongFaces then - LongFaces = MainFaces.LongFaces - else - LongFaces = GetLongFaces( Proc, MainFaces) + if not LongFaces[1].MainEdges.SideEdges[2].bIsOpen then + idSecondSideFace = LongFaces[1].MainEdges.SideEdges[2].idAdjacentFace end - - for i = 1, Proc.nFct do - if not idBottomFace or i ~= ( idBottomFace + 1) then - local bIsSideFace = true - for j = 1, #LongFaces do - if Proc.Faces[i].id == LongFaces[j].id then - bIsSideFace = false - break - end - end - if bIsSideFace then - table.insert( SideFaces, Proc.Faces[i]) - SideFaces[#SideFaces].Type = 'Side' - end - end + if idFirstSideFace > -1 then + table.insert( SideFaces, Proc.Faces[idFirstSideFace + 1]) + SideFaces[#SideFaces].Type = 'Side' + end + if idSecondSideFace > -1 then + table.insert( SideFaces, Proc.Faces[idSecondSideFace + 1]) + SideFaces[#SideFaces].Type = 'Side' end -- TODO aggiungere anche informazioni Edges?? diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index bb6ff78..96049df 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -64,10 +64,10 @@ local function GetToolEntryAngle( Proc, vtTool) function MachiningLib.GetMachiningSteps( dMachiningDepth, dStep) local MachiningSteps = {} - MachiningSteps.StepLength = 0 - MachiningSteps.Count = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) - if MachiningSteps.Count > 1 then - MachiningSteps.StepLength = ( dMachiningDepth - dStep) / ( MachiningSteps.Count - 1) + MachiningSteps.dStepLength = 0 + MachiningSteps.nCount = ceil( ( dMachiningDepth - 10 * GEO.EPS_SMALL) / dStep) + if MachiningSteps.nCount > 1 then + MachiningSteps.dStepLength = ( dMachiningDepth - dStep) / ( MachiningSteps.nCount - 1) end return MachiningSteps @@ -175,10 +175,15 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) for i = 1, #TOOLS do local bIsToolCompatible = true + -- TODO non va bene - da sistemare!!!!! + if TOOLS[i].sFamily ~= 'SAWBLADE' then + bIsToolCompatible = false + end + if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then - bIsToolCompatible = TOOLS[i].bIsTopHead + bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then - bIsToolCompatible = TOOLS[i].bIsBottomHead + bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead end if bIsToolCompatible then @@ -201,7 +206,6 @@ end ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo SEGA A CATENA con certe caratteristiche -- TODO da completare --- TODO implementare sorting in base a sSortingCriterion function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) local ToolInfo = {} @@ -222,7 +226,6 @@ function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) -- parametri opzionali ToolSearchParameters.dElevation = ToolSearchParameters.dElevation or 0 ToolSearchParameters.bExtendWithCornerRadius = ToolSearchParameters.bExtendWithCornerRadius or false - ToolSearchParameters.sSortingCriterion = ToolSearchParameters.sSortingCriterion or 'Standard' local nBestToolIndex local dBestToolResidualDepth = 0 @@ -230,9 +233,9 @@ function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) local bIsToolCompatible = true if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then - bIsToolCompatible = TOOLS[i].bIsTopHead + bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then - bIsToolCompatible = TOOLS[i].bIsBottomHead + bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead end -- TODO nei confronti tra valori gestire tolleranze diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua index 608a126..dd45245 100644 --- a/Strategies/STR0003/STR0003.lua +++ b/Strategies/STR0003/STR0003.lua @@ -20,10 +20,10 @@ local Chainsaw = {} local function IsTopologyOk( Proc) - if Proc.TopologyLongName == 'Pocket-Blind-RightAngles-Parallel-5' or - Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' or - Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or - Proc.TopologyLongName == 'Tunnel-Through-RightAngles-Parallel-4' then + if 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 return true else @@ -31,6 +31,7 @@ local function IsTopologyOk( Proc) end end +-- TODO da eliminare function GetToolFromMachining( sMachiningName) local Tool = {} if EgtMdbSetCurrMachining( sMachiningName) then @@ -67,16 +68,16 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) -- TODO implementare le funzioni di Tool Collision Avoidance (vedi wiki e FacesBysaw -> CalcLeadInOutPerpGeom) -- si determina l'eventuale riduzione da applicare in caso di inizio o fine chiusi - local bIsMortising = ( Machining.Type == MCH_OY.MORTISING) + local bIsMortising = ( Machining.nType == MCH_OY.MORTISING) local dAddLengthToReduce = 0 if bIsMortising then - dAddLengthToReduce = Machining.Tool.Diameter / 2 + dAddLengthToReduce = TOOLS[Machining.nToolIndex].dDiameter / 2 else - dAddLengthToReduce = sqrt( Machining.Depth * Machining.Tool.Diameter - Machining.Depth * Machining.Depth) + dAddLengthToReduce = sqrt( Machining.dDepthToMachine * TOOLS[Machining.nToolIndex].dDiameter - Machining.dDepthToMachine * Machining.dDepthToMachine) end - if Machining.Invert then - Machining.IsStartClosed, Machining.IsEndClosed = Machining.IsEndClosed, Machining.IsStartClosed + if Machining.bInvert then + Machining.bIsStartClosed, Machining.bIsEndClosed = Machining.bIsEndClosed, Machining.bIsStartClosed end local LeadIn = {} @@ -88,9 +89,9 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadOut.Type = MCH_MILL_LI.LINEAR LeadIn.TangentDistance = 0 LeadOut.TangentDistance = 0 - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - LeadIn.PerpDistance = EdgeToMachine.Elevation + BeamData.CUT_SIC - LeadOut.PerpDistance = EdgeToMachine.Elevation + BeamData.CUT_SIC + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + LeadIn.PerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC + LeadOut.PerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC else LeadIn.PerpDistance = BeamData.CUT_SIC LeadOut.PerpDistance = BeamData.CUT_SIC @@ -99,28 +100,28 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) LeadOut.Elevation = 0 LeadIn.CompLength = 0 LeadOut.CompLength = 0 - if Machining.IsStartClosed and Machining.IsEndClosed then + if Machining.bIsStartClosed and Machining.bIsEndClosed then LeadIn.StartAddLength = -dAddLengthToReduce LeadOut.EndAddLength = -dAddLengthToReduce - elseif Machining.IsStartClosed then + elseif Machining.bIsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.Length + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) - elseif Machining.IsEndClosed then + LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + elseif Machining.bIsEndClosed then LeadOut.EndAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.Length + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) else LeadIn.StartAddLength = BeamData.CUT_EXTRA LeadOut.EndAddLength = BeamData.CUT_EXTRA end else - if Machining.IsStartClosed then + if Machining.bIsStartClosed then LeadIn.StartAddLength = -dAddLengthToReduce else LeadIn.StartAddLength = BeamData.CUT_EXTRA end - if Machining.IsEndClosed then + if Machining.bIsEndClosed then LeadOut.EndAddLength = -dAddLengthToReduce else LeadOut.EndAddLength = BeamData.CUT_EXTRA @@ -133,9 +134,9 @@ end local function AddNewMachining( Machining, b3Raw) local sErr = '' - local nOperationId = EgtAddMachining( Machining.OperationName, Machining.Name) + local nOperationId = EgtAddMachining( Machining.sOperationName, Machining.Nsame) if not nOperationId then - sErr = 'Error adding machining ' .. Machining.OperationName .. '-' .. Machining.Name + sErr = 'Error adding machining ' .. Machining.sOperationName .. '-' .. Machining.sName EgtOutLog( sErr) return false, sErr end @@ -143,43 +144,43 @@ local function AddNewMachining( Machining, b3Raw) -- impostazione parametri lavorazione local sUserNotes = EgtGetMachiningParam( MCH_MP.USERNOTES) EgtSetMachiningGeometry( Machining.Geometry) - EgtSetMachiningParam( MCH_MP.FACEUSE, Machining.Faceuse) - EgtSetMachiningParam( MCH_MP.SCC, Machining.SCC) - EgtSetMachiningParam( MCH_MP.INVERT, Machining.Invert) - EgtSetMachiningParam( MCH_MP.WORKSIDE, Machining.Workside) - EgtSetMachiningParam( MCH_MP.TOOLINVERT, Machining.ToolInvert) - EgtSetMachiningParam( MCH_MP.OFFSR, Machining.RadialOffset) - EgtSetMachiningParam( MCH_MP.OFFSL, Machining.LongitudinalOffset) + EgtSetMachiningParam( MCH_MP.FACEUSE, Machining.nFaceuse) + EgtSetMachiningParam( MCH_MP.SCC, Machining.nSCC) + EgtSetMachiningParam( MCH_MP.INVERT, Machining.bInvert) + EgtSetMachiningParam( MCH_MP.WORKSIDE, Machining.nWorkside) + EgtSetMachiningParam( MCH_MP.TOOLINVERT, Machining.bToolInvert) + EgtSetMachiningParam( MCH_MP.OFFSR, Machining.dRadialOffset) + EgtSetMachiningParam( MCH_MP.OFFSL, Machining.dLongitudinalOffset) if Machining.Type ~= MCH_OY.MORTISING then - EgtSetMachiningParam( MCH_MP.LEADINTYPE, Machining.LeadIn.Type) - EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, Machining.LeadOut.Type) - EgtSetMachiningParam( MCH_MP.LITANG, Machining.LeadIn.TangentDistance) - EgtSetMachiningParam( MCH_MP.LOTANG, Machining.LeadOut.TangentDistance) - EgtSetMachiningParam( MCH_MP.LIPERP, Machining.LeadIn.PerpDistance) - EgtSetMachiningParam( MCH_MP.LOPERP, Machining.LeadOut.PerpDistance) - EgtSetMachiningParam( MCH_MP.LIELEV, Machining.LeadIn.Elevation) - EgtSetMachiningParam( MCH_MP.LOELEV, Machining.LeadOut.Elevation) - EgtSetMachiningParam( MCH_MP.LICOMPLEN, Machining.LeadIn.CompLength) - EgtSetMachiningParam( MCH_MP.LOCOMPLEN, Machining.LeadOut.CompLength) + EgtSetMachiningParam( MCH_MP.LEADINTYPE, Machining.LeadIn.nType) + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, Machining.LeadOut.nType) + EgtSetMachiningParam( MCH_MP.LITANG, Machining.LeadIn.dTangentDistance) + EgtSetMachiningParam( MCH_MP.LOTANG, Machining.LeadOut.dTangentDistance) + EgtSetMachiningParam( MCH_MP.LIPERP, Machining.LeadIn.dPerpDistance) + EgtSetMachiningParam( MCH_MP.LOPERP, Machining.LeadOut.dPerpDistance) + EgtSetMachiningParam( MCH_MP.LIELEV, Machining.LeadIn.dElevation) + EgtSetMachiningParam( MCH_MP.LOELEV, Machining.LeadOut.dElevation) + EgtSetMachiningParam( MCH_MP.LICOMPLEN, Machining.LeadIn.dCompLength) + EgtSetMachiningParam( MCH_MP.LOCOMPLEN, Machining.LeadOut.dCompLength) end - EgtSetMachiningParam( MCH_MP.STARTADDLEN, Machining.LeadIn.StartAddLength) - EgtSetMachiningParam( MCH_MP.ENDADDLEN, Machining.LeadOut.EndAddLength) + EgtSetMachiningParam( MCH_MP.STARTADDLEN, Machining.LeadIn.dStartAddLength) + EgtSetMachiningParam( MCH_MP.ENDADDLEN, Machining.LeadOut.dEndAddLength) if Machining.Steps then - if Machining.Steps.StepType then - EgtSetMachiningParam( MCH_MP.STEPTYPE, Machining.Steps.StepType) + if Machining.Steps.nStepType then + EgtSetMachiningParam( MCH_MP.STEPTYPE, Machining.Steps.nStepType) end - if Machining.Steps.StepLength then - EgtSetMachiningParam( MCH_MP.STEP, Machining.Steps.StepLength) + if Machining.Steps.dStepLength then + EgtSetMachiningParam( MCH_MP.STEP, Machining.Steps.dStepLength) end end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) - if Machining.Type == MCH_OY.MORTISING then - EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.sName, Machining.BlockedAxis.sOrientation, b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) + if Machining.nType == MCH_OY.MORTISING then + EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.vtN, Machining.SuggestedAngles.vtOrtho, Machining.SuggestedAngles.nIndex)) end - EgtSetMachiningParam( MCH_MP.OVERL, Machining.Overlap) - EgtSetMachiningParam( MCH_MP.STARTPOS, max( Machining.StartSafetyLength, EgtGetMachiningParam( MCH_MP.STARTPOS))) - if Machining.MaxElev then - sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', Machining.MaxElev) + EgtSetMachiningParam( MCH_MP.OVERL, Machining.dOverlap) + EgtSetMachiningParam( MCH_MP.STARTPOS, max( Machining.dStartSafetyLength, EgtGetMachiningParam( MCH_MP.STARTPOS))) + if Machining.dMaxElev then + sUserNotes = EgtSetValInNotes( sUserNotes, 'MaxElev', Machining.dMaxElev) end EgtSetMachiningParam( MCH_MP.USERNOTES, sUserNotes) @@ -189,19 +190,19 @@ local function AddNewMachining( Machining, b3Raw) nErr, sErr = EgtGetLastMachMgrError() -- se mortasatura e l'errore è compatibile (Axes values not calculable) si prova con l'altra configurazione dell'asse bloccato -- TODO valutare se c'è modo di capire preventivamente la configurazione dell'asse bloccato e quindi rimuovere questa parte di codice - if Machining.Type == MCH_OY.MORTISING and nErr == 2507 then - if Machining.BlockedAxis.Orientation == 'perpendicular' then - Machining.BlockedAxis.Orientation = 'parallel' + if Machining.nType == MCH_OY.MORTISING and nErr == 2507 then + if Machining.BlockedAxis.sOrientation == 'perpendicular' then + Machining.BlockedAxis.sOrientation = 'parallel' else - Machining.BlockedAxis.Orientation = 'perpendicular' + Machining.BlockedAxis.sOrientation = 'perpendicular' end - EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.Name, Machining.BlockedAxis.Orientation, b3Raw, Machining.BlockedAxis.VtN, Machining.BlockedAxis.VtOut)) - if Machining.SuggestedAngles.Index == 1 then - Machining.SuggestedAngles.Index = 2 + EgtSetMachiningParam( MCH_MP.BLOCKEDAXIS, BeamLib.GetBlockedAxis( Machining.sName, Machining.BlockedAxis.sOrientation, b3Raw, Machining.BlockedAxis.vtN, Machining.BlockedAxis.vtOut)) + if Machining.SuggestedAngles.nIndex == 1 then + Machining.SuggestedAngles.nIndex = 2 else - Machining.SuggestedAngles.Index = 1 + Machining.SuggestedAngles.nIndex = 1 end - EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.VtN, Machining.SuggestedAngles.VtOrtho, Machining.SuggestedAngles.Index)) + EgtSetMachiningParam( MCH_MP.INITANGS, BeamLib.GetChainSawInitAngs( Machining.SuggestedAngles.vtN, Machining.SuggestedAngles.vtOrtho, Machining.SuggestedAngles.nIndex)) sErr = '' bIsApplyOk = EgtApplyMachining( true, false) end @@ -239,153 +240,149 @@ end function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Cutting = {} - Cutting.CanApply = true - Cutting.Message = '' - Cutting.ProcId = Proc.id + Cutting.bCanApply = true + Cutting.sMessage = '' + Cutting.idProc = Proc.id local dPocketHeight = 0 - if Proc.Topology == 'Tunnel' then - dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + if Proc.Topology.sFamily == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.dHeight else if FaceToMachine.Type == 'Long' then - dPocketHeight = Proc.MainFaces.BottomFace.Edges.SideEdges[1].Length + dPocketHeight = Proc.MainFaces.BottomFace.MainEdges.SideEdges[1].dLength elseif FaceToMachine.Type == 'Side' then - dPocketHeight = Proc.MainFaces.BottomFace.Edges.LongEdges[1].Length + dPocketHeight = Proc.MainFaces.BottomFace.MainEdges.LongEdges[1].dLength end end -- ricerca utensile local ToolSearchParameters = {} - ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) - ToolSearchParameters.vtToolDirection = EdgeToMachine.ToolDirection + ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) + ToolSearchParameters.vtToolDirection = EdgeToMachine.vtToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = false ToolSearchParameters.bForceLongcutBlade = Strategy.Parameters.bForceLongcutBlade local ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - if not ToolInfo.nToolIndex then - ToolSearchParameters.dElevation = 0 - ToolInfo = MachiningLib.FindBlade( Proc, ToolSearchParameters) - end - if not Cutting.Name then - Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - saw blade not found' - Cutting.CanApply = false - EgtOutLog( Cutting.Message) + Cutting.nToolIndex = ToolInfo.nToolIndex + Cutting.nType = MCH_OY.MILLING + if not TOOLS[Cutting.nToolIndex].sName then + Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - saw blade not found' + Cutting.bCanApply = false + EgtOutLog( Cutting.sMessage) return Cutting end - Cutting.nToolIndex = ToolInfo.nToolIndex - Cutting.Type = MCH_OY.MILLING -- verifica dimensioni tasca compatibili -- se tasca meno spessa della lama la strategia non è applicabile - if Cutting.TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then - Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade thickness' - Cutting.CanApply = false - EgtOutLog( Cutting.Message) + if TOOLS[Cutting.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then + Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade thickness' + Cutting.bCanApply = false + EgtOutLog( Cutting.sMessage) return Cutting end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile - if Cutting.TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then - Cutting.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade diameter' - Cutting.CanApply = false - EgtOutLog( Cutting.Message) + if TOOLS[Cutting.nToolIndex].dDiameter > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then + Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade diameter' + Cutting.bCanApply = false + EgtOutLog( Cutting.sMessage) return Cutting end end -- parametri della lavorazione -- inizio e fine aperti o chiusi - Cutting.IsStartClosed = not EdgeToMachine.IsStartOpen - Cutting.IsEndClosed = not EdgeToMachine.IsEndOpen + Cutting.bIsStartClosed = not EdgeToMachine.bIsStartOpen + Cutting.bIsEndClosed = not EdgeToMachine.bIsEndOpen -- lato di lavoro e inversioni - if Cutting.TOOLS[Cutting.nToolIndex].bIsCCW then - Cutting.Workside = MCH_MILL_WS.RIGHT - Cutting.Invert = true + if TOOLS[Cutting.nToolIndex].bIsCCW then + Cutting.nWorkside = MCH_MILL_WS.RIGHT + Cutting.bInvert = true else - Cutting.Workside = MCH_MILL_WS.LEFT - Cutting.Invert = false + Cutting.nWorkside = MCH_MILL_WS.LEFT + Cutting.bInvert = false end - if EdgeToMachine.Elevation < -10 * GEO.EPS_SMALL then - Cutting.Invert = not Cutting.Invert + if EdgeToMachine.dElevation < -10 * GEO.EPS_SMALL then + Cutting.bInvert = not Cutting.bInvert end -- TODO gestire lama da sotto e lama downUp - if FaceToMachine.VtN:getZ() < - 10 * GEO.EPS_SMALL then - Cutting.ToolInvert = true - Cutting.Invert = not Cutting.Invert + if FaceToMachine.vtN:getZ() < - 10 * GEO.EPS_SMALL then + Cutting.bToolInvert = true + Cutting.bInvert = not Cutting.bInvert else - Cutting.ToolInvert = false + Cutting.bToolInvert = false end -- profondità e offset radiale - if Cutting.TOOLS[Cutting.nToolIndex].dMaxDepth > abs( EdgeToMachine.Elevation) - 10 * GEO.EPS_SMALL then + if TOOLS[Cutting.nToolIndex].dMaxDepth > abs( EdgeToMachine.dElevation) - 10 * GEO.EPS_SMALL then -- TODO la depth dovrebbe essere quella del machining - Cutting.Depth = abs( EdgeToMachine.Elevation) - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - Cutting.RadialOffset = 0 + Cutting.dDepthToMachine = abs( EdgeToMachine.dElevation) + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + Cutting.dRadialOffset = 0 else - Cutting.RadialOffset = EdgeToMachine.Elevation + Cutting.dRadialOffset = EdgeToMachine.dElevation end else - Cutting.Depth = Cutting.TOOLS[Cutting.nToolIndex].MaxDepth - 1 - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - Cutting.RadialOffset = EdgeToMachine.Elevation - Cutting.Depth + Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].MaxDepth - 1 + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine else - Cutting.RadialOffset = -Cutting.Depth + Cutting.dRadialOffset = -Cutting.dDepthToMachine end - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL and Strategy.Parameters.bApplyOnlyBlade then - Cutting.Message = 'Feature '.. Proc.idFeature .. ' : sawblade elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Cutting.Depth, 1) .. ')' - EgtOutLog( Cutting.Message) + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL and Strategy.Parameters.bApplyOnlyBlade then + Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : sawblade elevation (' .. EgtNumToString( EdgeToMachine.dElevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Cutting.dDepthToMachine, 1) .. ')' + EgtOutLog( Cutting.sMessage) end end -- step verticale e offset longitudinale - Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, Cutting.TOOLS[Cutting.nToolIndex].dThickness) + Cutting.Steps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Cutting.nToolIndex].dThickness) Cutting.Steps.StepType = MCH_MILL_ST.ONEWAY - Cutting.MaxElev = Cutting.Steps.StepLength * Cutting.Steps.Count - 10 * GEO.EPS_SMALL - if Cutting.ToolInvert and Cutting.Steps.Count > 1 then - Cutting.LongitudinalOffset = - dPocketHeight + Cutting.dMaxElev = Cutting.Steps.dStepLength * Cutting.Steps.nCount - 10 * GEO.EPS_SMALL + if Cutting.bToolInvert and Cutting.Steps.nCount > 1 then + Cutting.dLongitudinalOffset = - dPocketHeight else - Cutting.LongitudinalOffset = 0 + Cutting.dLongitudinalOffset = 0 end -- distanza di sicurezza - Cutting.StartSafetyLength = 10 + Cutting.dStartSafetyLength = 10 -- overlap - Cutting.Overlap = 0 + Cutting.dOverlap = 0 -- faceuse - if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then - Cutting.Faceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.ToolDirection) + if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( EdgeToMachine.vtToolDirection) else - Cutting.Faceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.ToolDirection) + Cutting.nFaceuse = BeamLib.GetNearestOrthoOpposite( -EdgeToMachine.vtToolDirection) end -- SCC - Cutting.SCC = Blade.GetSCC( EdgeToMachine.ToolDirection) + Cutting.nSCC = Blade.GetSCC( EdgeToMachine.vtToolDirection) -- asse bloccato Cutting.BlockedAxis = {} - Cutting.BlockedAxis.Orientation = 'perpendicular' - Cutting.BlockedAxis.VtN = FaceToMachine.VtN - Cutting.BlockedAxis.VtOut = EgtIf( FaceToMachine.VtN:getX() > 0, X_AX(), -X_AX()) + Cutting.BlockedAxis.sOrientation = 'perpendicular' + Cutting.BlockedAxis.vtN = FaceToMachine.vtN + Cutting.BlockedAxis.vtOut = EgtIf( FaceToMachine.vtN:getX() > 0, X_AX(), -X_AX()) -- approccio e retrazione Cutting.LeadIn, Cutting.LeadOut = CalculateLeadInOut( Cutting, EdgeToMachine) -- eventuale step orizzontale Cutting.HorizontalSteps = {} - if Cutting.TOOLS[Cutting.nToolIndex].dSideStep then - Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.Depth, Cutting.TOOLS[Cutting.nToolIndex].dSideStep) + if TOOLS[Cutting.nToolIndex].dSideStep then + Cutting.HorizontalSteps = MachiningLib.GetMachiningSteps( Cutting.dDepthToMachine, TOOLS[Cutting.nToolIndex].dSideStep) else - Cutting.HorizontalSteps.Count = 1 - Cutting.HorizontalSteps.StepLength = 0 + Cutting.HorizontalSteps.nCount = 1 + Cutting.HorizontalSteps.dStepLength = 0 end -- geometria Cutting.Geometry = {{Proc.id, FaceToMachine.id}} -- nome operazione - Cutting.OperationName = 'Cut_' .. ( EgtGetName( Cutting.ProcId) or tostring( Cutting.ProcId)) .. '_' .. tostring( FaceToMachine.id + 1) + Cutting.sOperationName = 'Cut_' .. ( EgtGetName( Cutting.idProc) or tostring( Cutting.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) -- eventuale avviso di danneggiamento pezzo successivo -- TODO da sostituire con check se si riesce a separare e il grezzo dietro è lungo a sufficienza - local dOffsideLength = max( Cutting.LeadIn.StartAddLength, Cutting.LeadOut.EndAddLength) + Cutting.TOOLS[Cutting.nToolIndex].dDiameter / 2 + 10 * GEO.EPS_SMALL + local dOffsideLength = max( Cutting.LeadIn.dStartAddLength, Cutting.LeadOut.dEndAddLength) + TOOLS[Cutting.nToolIndex].dDiameter / 2 + 10 * GEO.EPS_SMALL if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : sawblade can damage next piece.' - if #Cutting.Message > 0 then - Cutting.Message = Cutting.Message .. '\n' .. sDamageNextPieceMessage + if #Cutting.sMessage > 0 then + Cutting.sMessage = Cutting.sMessage .. '\n' .. sDamageNextPieceMessage else - Cutting.Message = sDamageNextPieceMessage + Cutting.sMessage = sDamageNextPieceMessage end EgtOutLog( sDamageNextPieceMessage) end @@ -398,14 +395,14 @@ function Blade.AddMachiningAllSteps( Cutting, b3Raw) local bIsCuttingOk = false local sCuttingApplyMessage = '' - local dOriginalRadialOffset = Cutting.RadialOffset - local dOriginalLeadInPerpDistance = Cutting.LeadIn.PerpDistance - local dOriginalLeadOutPerpDistance = Cutting.LeadOut.PerpDistance - for i = Cutting.HorizontalSteps.Count, 1, -1 do - Cutting.RadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.StepLength * ( i - 1) + local dOriginalRadialOffset = Cutting.dRadialOffset + local dOriginalLeadInPerpDistance = Cutting.LeadIn.dPerpDistance + local dOriginalLeadOutPerpDistance = Cutting.LeadOut.dPerpDistance + for i = Cutting.HorizontalSteps.nCount, 1, -1 do + Cutting.dRadialOffset = dOriginalRadialOffset + Cutting.HorizontalSteps.dStepLength * ( i - 1) -- update distanza perpendicolare attacco per contemplare l'offset applicato - Cutting.LeadIn.PerpDistance = dOriginalLeadInPerpDistance - Cutting.RadialOffset - Cutting.LeadOut.PerpDistance = dOriginalLeadOutPerpDistance - Cutting.RadialOffset + Cutting.LeadIn.dPerpDistance = dOriginalLeadInPerpDistance - Cutting.dRadialOffset + Cutting.LeadOut.dPerpDistance = dOriginalLeadOutPerpDistance - Cutting.dRadialOffset -- applicazione lavorazione bIsCuttingOk, sCuttingApplyMessage = AddNewMachining( Cutting, b3Raw) -- update messaggi @@ -420,52 +417,52 @@ end function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) local Mortising = {} - Mortising.CanApply = true - Mortising.Message = '' - Mortising.ProcId = Proc.id + Mortising.bCanApply = true + Mortising.sMessage = '' + Mortising.idProc = Proc.id local bNeedToMachineOtherSide = false -- OneSide | OneSideAndExtend | BothSides | BothSidesAndExtend local sMortisingType local dPocketHeight = 0 - if Proc.Topology == 'Tunnel' then - dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.Height + if Proc.Topology.sFamily == 'Tunnel' then + dPocketHeight = Proc.MainFaces.TunnelAddedFaces.MiddleFaceTm.dHeight else if FaceToMachine.Type == 'Long' then - dPocketHeight = Proc.MainFaces.BottomFace.Edges.SideEdges[1].Length + dPocketHeight = Proc.MainFaces.BottomFace.MainEdges.SideEdges[1].dLength elseif FaceToMachine.Type == 'Side' then - dPocketHeight = Proc.MainFaces.BottomFace.Edges.LongEdges[1].Length + dPocketHeight = Proc.MainFaces.BottomFace.MainEdges.LongEdges[1].dLength end end -- ricerca utensile local ToolSearchParameters = {} local ToolInfo = {} - ToolSearchParameters.vtToolDirection = EdgeToMachine.ToolDirection + ToolSearchParameters.vtToolDirection = EdgeToMachine.vtToolDirection ToolSearchParameters.bAllowTopHead = true ToolSearchParameters.bAllowBottomHead = false - if Proc.Topology == 'Tunnel' then + if Proc.Topology.sFamily == 'Tunnel' then sMortisingType = 'OneSideAndExtend' ToolSearchParameters.bExtendWithCornerRadius = true - ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) + BeamData.CUT_EXTRA + ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) + BeamData.CUT_EXTRA ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) - if not TOOLS[ToolInfo.nToolIndex].sName then + if ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL then sMortisingType = 'BothSidesAndExtend' - ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) / 2 + BeamData.CUT_EXTRA_MIN + ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) / 2 + BeamData.CUT_EXTRA_MIN ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end - elseif EdgeToMachine.Type == 'Side' and #( Proc.MainFaces.SideFaces) == 0 then + elseif EdgeToMachine.sType == 'Side' and #( Proc.MainFaces.SideFaces) == 0 then sMortisingType = 'BothSidesAndExtend' ToolSearchParameters.bExtendWithCornerRadius = true - ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) / 2 + BeamData.CUT_EXTRA_MIN + ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) / 2 + BeamData.CUT_EXTRA_MIN ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) else sMortisingType = 'OneSide' ToolSearchParameters.bExtendWithCornerRadius = false - ToolSearchParameters.dElevation = abs( EdgeToMachine.Elevation) + BeamData.CUT_EXTRA + ToolSearchParameters.dElevation = abs( EdgeToMachine.dElevation) + BeamData.CUT_EXTRA ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end - if not TOOLS[ToolInfo.nToolIndex].sName then + if ToolInfo.dResidualDepth > 10 * GEO.EPS_SMALL then if sMortisingType == 'BothSidesAndExtend' then sMortisingType = 'BothSides' elseif sMortisingType == 'OneSideAndExtend' then @@ -473,116 +470,115 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end ToolSearchParameters.bExtendWithCornerRadius = false ToolSearchParameters.dElevation = nil - ToolSearchParameters.sSortingCriterion = 'Longest' ToolInfo = MachiningLib.FindChainSaw( Proc, ToolSearchParameters) end - if not TOOLS[ToolInfo.nToolIndex].sName then - Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - chainsaw not found' - Mortising.CanApply = false - EgtOutLog( Mortising.Message) + Mortising.nToolIndex = ToolInfo.nToolIndex + Mortising.nType = MCH_OY.MORTISING + if not TOOLS[Mortising.nToolIndex].sName then + Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - chainsaw not found' + Mortising.bCanApply = false + EgtOutLog( Mortising.sMessage) return Mortising, false end - Mortising.nToolIndex = ToolInfo.nToolIndex - Mortising.Type = MCH_OY.MORTISING -- verifica dimensioni tasca compatibili -- se tasca meno spessa della sega a catena la strategia non è applicabile - if Mortising.TOOLS[Mortising.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then - Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw thickness' - Mortising.CanApply = false - EgtOutLog( Mortising.Message) + if TOOLS[Mortising.nToolIndex].dThickness > dPocketHeight + 10 * GEO.EPS_SMALL then + Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw thickness' + Mortising.bCanApply = false + EgtOutLog( Mortising.sMessage) return Mortising, false end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile - if Mortising.TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.Length + 10 * GEO.EPS_SMALL then - Mortising.Message = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw width' - Mortising.CanApply = false - EgtOutLog( Mortising.Message) + if TOOLS[Mortising.nToolIndex].dWidth > EdgeToMachine.dLength + 10 * GEO.EPS_SMALL then + Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw width' + Mortising.bCanApply = false + EgtOutLog( Mortising.sMessage) return Mortising, false end end -- parametri della lavorazione -- inizio e fine aperti o chiusi - Mortising.IsStartClosed = not EdgeToMachine.IsStartOpen - Mortising.IsEndClosed = not EdgeToMachine.IsEndOpen + Mortising.bIsStartClosed = not EdgeToMachine.bIsStartOpen + Mortising.bIsEndClosed = not EdgeToMachine.bIsEndOpen -- lato di lavoro e inversioni - Mortising.Invert = false - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - Mortising.Workside = MCH_MILL_WS.RIGHT - Mortising.ToolInvert = false + Mortising.bInvert = false + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + Mortising.nWorkside = MCH_MILL_WS.RIGHT + Mortising.bToolInvert = false else - Mortising.Workside = MCH_MILL_WS.LEFT - Mortising.ToolInvert = true + Mortising.nWorkside = MCH_MILL_WS.LEFT + Mortising.bToolInvert = true end -- profondità e offset longitudinale if sMortisingType == 'OneSide' then - Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) elseif sMortisingType == 'OneSideAndExtend' then - Mortising.Depth = abs( EdgeToMachine.Elevation) + Mortising.TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN + Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) + TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN elseif sMortisingType == 'BothSides' then - Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) / 2 bNeedToMachineOtherSide = true elseif sMortisingType == 'BothSidesAndExtend' then - Mortising.Depth = abs( EdgeToMachine.Elevation) / 2 + Mortising.TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN + Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) / 2 + TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN bNeedToMachineOtherSide = true end - if Mortising.TOOLS[Mortising.nToolIndex].dMaxMat > Mortising.Depth - 10 * GEO.EPS_SMALL then - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - Mortising.LongitudinalOffset = 0 + if TOOLS[Mortising.nToolIndex].dMaxMat > Mortising.dDepthToMachine - 10 * GEO.EPS_SMALL then + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + Mortising.dLongitudinalOffset = 0 else - Mortising.LongitudinalOffset = abs( EdgeToMachine.Elevation) - Mortising.Depth + Mortising.dLongitudinalOffset = abs( EdgeToMachine.dElevation) - Mortising.dDepthToMachine end else - Mortising.Depth = Mortising.TOOLS[Mortising.nToolIndex].dMaxMat - 1 - if EdgeToMachine.Elevation > -10 * GEO.EPS_SMALL then - Mortising.LongitudinalOffset = EdgeToMachine.Elevation - Mortising.Depth + Mortising.dDepthToMachine = TOOLS[Mortising.nToolIndex].dMaxMat - 1 + if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then + Mortising.dLongitudinalOffset = EdgeToMachine.dElevation - Mortising.dDepthToMachine else - Mortising.LongitudinalOffset = 0 + Mortising.dLongitudinalOffset = 0 end - Mortising.Message = 'Feature '.. Proc.idFeature .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.Elevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.Depth, 1) .. ')' - EgtOutLog( Mortising.Message) + Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw elevation (' .. EgtNumToString( EdgeToMachine.dElevation, 1) .. ') bigger than max tool depth (' .. EgtNumToString( Mortising.dDepthToMachine, 1) .. ')' + EgtOutLog( Mortising.sMessage) end -- offset radiale - Mortising.RadialOffset = 0 + Mortising.dRadialOffset = 0 -- distanza di sicurezza - Mortising.StartSafetyLength = EdgeToMachine.Elevation + Mortising.dStartSafetyLength = EdgeToMachine.dElevation -- overlap - Mortising.Overlap = 0 + Mortising.dOverlap = 0 -- faceuse - if EdgeToMachine.Elevation > - 10 * GEO.EPS_SMALL then - Mortising.Faceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.ToolDirection) + if EdgeToMachine.dElevation > - 10 * GEO.EPS_SMALL then + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( EdgeToMachine.vtToolDirection) else - Mortising.Faceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.ToolDirection) + Mortising.nFaceuse = BeamLib.GetNearestParalOpposite( -EdgeToMachine.vtToolDirection) end -- SCC Mortising.SCC = MCH_SCC.NONE -- asse bloccato e angoli suggeriti Mortising.BlockedAxis = {} - Mortising.BlockedAxis.Orientation = 'perpendicular' - Mortising.BlockedAxis.VtN = FaceToMachine.VtN + Mortising.BlockedAxis.sOrientation = 'perpendicular' + Mortising.BlockedAxis.vtN = FaceToMachine.vtN Mortising.SuggestedAngles = {} - Mortising.SuggestedAngles.Index = 1 - Mortising.SuggestedAngles.VtN = FaceToMachine.VtN - Mortising.SuggestedAngles.VtOrthO = EdgeToMachine.ToolDirection + Mortising.SuggestedAngles.nIndex = 1 + Mortising.SuggestedAngles.vtN = FaceToMachine.vtN + Mortising.SuggestedAngles.vtOrthO = EdgeToMachine.vtToolDirection -- approccio e retrazione Mortising.LeadIn, Mortising.LeadOut = CalculateLeadInOut( Mortising, EdgeToMachine) -- eventuale step verticale - Mortising.VerticalSteps = MachiningLib.GetMachiningSteps( dPocketHeight, Mortising.TOOLS[Mortising.nToolIndex].dThickness) + Mortising.VerticalSteps = MachiningLib.GetMachiningSteps( dPocketHeight, TOOLS[Mortising.nToolIndex].dThickness) -- geometria Mortising.Geometry = {{Proc.id, FaceToMachine.id}} -- nome operazione - Mortising.OperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.ProcId) or tostring( Mortising.ProcId)) .. '_' .. tostring( FaceToMachine.id + 1) + Mortising.sOperationName = 'Chainsaw_' .. ( EgtGetName( Mortising.idProc) or tostring( Mortising.idProc)) .. '_' .. tostring( FaceToMachine.id + 1) -- eventuale avviso di danneggiamento pezzo successivo - local dOffsideLength = max( Mortising.LeadIn.StartAddLength, Mortising.LeadOut.EndAddLength) + Mortising.TOOLS[Mortising.nToolIndex].dWidth / 2 + 10 * GEO.EPS_SMALL + local dOffsideLength = max( Mortising.LeadIn.dStartAddLength, Mortising.LeadOut.dEndAddLength) + TOOLS[Mortising.nToolIndex].dWidth / 2 + 10 * GEO.EPS_SMALL if ( not Proc.Tail or Proc.AdvTail) and Proc.AffectedFaces.Left and ( Proc.DistanceToNextPart < dOffsideLength) then local sDamageNextPieceMessage = 'Feature '.. Proc.idFeature .. ' : chainsaw can damage next piece.' - if #Mortising.Message > 0 then - Mortising.Message = Mortising.Message .. '\n' .. sDamageNextPieceMessage + if #Mortising.sMessage > 0 then + Mortising.sMessage = Mortising.sMessage .. '\n' .. sDamageNextPieceMessage else - Mortising.Message = sDamageNextPieceMessage + Mortising.sMessage = sDamageNextPieceMessage end EgtOutLog( sDamageNextPieceMessage) end @@ -595,14 +591,14 @@ function Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) local bIsMortisingOk = false local sMortisingApplyMessage = '' - local dOriginalRadialOffsetMortising = Mortising.RadialOffset - for i = Mortising.VerticalSteps.Count, 1, -1 do - Mortising.RadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.StepLength * ( i - 1) + local dOriginalRadialOffsetMortising = Mortising.dRadialOffset + for i = Mortising.VerticalSteps.nCount, 1, -1 do + Mortising.dRadialOffset = dOriginalRadialOffsetMortising + Mortising.VerticalSteps.dStepLength * ( i - 1) -- applicazione lavorazione bIsMortisingOk, sMortisingApplyMessage = AddNewMachining( Mortising, b3Raw) -- update messaggi if sMortisingApplyMessage and #sMortisingApplyMessage > 0 then - Mortising.Message = Mortising.Message .. '\n' .. 'Apply : ' .. sMortisingApplyMessage + Mortising.sMessage = Mortising.sMessage .. '\n' .. 'Apply : ' .. sMortisingApplyMessage end end @@ -648,10 +644,10 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- lama -- lavorazione di lama - fondo della tasca o fino a massimo materiale se tunnel local Cutting = {} - if Proc.Topology == 'Tunnel' then - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + if Proc.Topology.sFamily == 'Tunnel' then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) else - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge) end local bIsCuttingOk = false if bAddMachining and Cutting.CanApply then @@ -662,8 +658,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end local dBottomDepthToMachine = Cutting.RadialOffset -- lato opposto del tunnel - if Proc.Topology == 'Tunnel' then - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + if Proc.Topology.sFamily == 'Tunnel' then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2]) bIsCuttingOk = false if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) @@ -675,8 +671,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato if Cutting.RadialOffset > 10 * GEO.EPS_SMALL then -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione - if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsStartOpen then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1]) bIsCuttingOk = false if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) @@ -686,8 +682,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end end -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione - if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsEndOpen then + Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2]) bIsCuttingOk = false if bAddMachining and Cutting.CanApply then bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) @@ -711,9 +707,9 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) local Mortising = {} local bNeedToMachineOtherSide = false if Proc.Topology == 'Tunnel' then - Mortising, bNeedToMachineOtherSide = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[1]) + Mortising, bNeedToMachineOtherSide = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) else - Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.BottomEdge) + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge) -- si lavora solo quanto non lavorato dalla lama Mortising.MaxElev = dBottomDepthToMachine + BeamData.CUT_EXTRA end @@ -723,7 +719,7 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end -- lato opposto del tunnel if Proc.Topology == 'Tunnel' and bNeedToMachineOtherSide then - Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.OppositeEdges[2]) + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2]) bIsMortisingOk = false if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) @@ -735,8 +731,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- se la sega a catena non è arrivata sul fondo e c'è almeno un lato aperto va lavorato if Mortising.LongitudinalOffset > 10 * GEO.EPS_SMALL then -- eventuale lavorazione di sega a catena - lato della tasca da cui inizia la lavorazione - if Proc.MainFaces.LongFace.Edges.BottomEdge.IsStartOpen then - Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.StartEdge) + if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsStartOpen then + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1]) bIsMortisingOk = false if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) @@ -746,8 +742,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end end -- eventuale lavorazione di sega a catena - lato della tasca in cui finisce la lavorazione - if Proc.MainFaces.LongFace.Edges.BottomEdge.IsEndOpen then - Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFace, Proc.MainFaces.LongFace.Edges.SideEdges.EndEdge) + if Proc.MainFaces.LongFace[1].MainEdges.BottomEdge.IsEndOpen then + Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].Edges.SideEdges[2]) bIsMortisingOk = false if bAddMachining and Mortising.CanApply then bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) From c7687419a66519ca6062ec90b2fca9c07259194b Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Fri, 24 May 2024 18:37:53 +0200 Subject: [PATCH 4/5] - in MachiningLib corrette FindBlade e FindChainsaw (ancora da completare ma funzionano) - in STR0003 altre modifiche nomi variabili --- LuaLibs/MachiningLib.lua | 29 +++++++++--------- Strategies/STR0003/STR0003.lua | 54 +++++++++++++++++----------------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 96049df..88f14a8 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -173,17 +173,14 @@ function MachiningLib.FindBlade( Proc, ToolSearchParameters) local nBestToolIndex for i = 1, #TOOLS do - local bIsToolCompatible = true + local bIsToolCompatible = false - -- TODO non va bene - da sistemare!!!!! - if TOOLS[i].sFamily ~= 'SAWBLADE' then - bIsToolCompatible = false - end - - if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then - bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead - elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then - bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead + if TOOLS[i].sFamily == 'SAWBLADE' then + if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead + elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then + bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead + end end if bIsToolCompatible then @@ -230,12 +227,14 @@ function MachiningLib.FindChainSaw( Proc, ToolSearchParameters) local nBestToolIndex local dBestToolResidualDepth = 0 for i = 1, #TOOLS do - local bIsToolCompatible = true + local bIsToolCompatible = false - if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then - bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead - elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then - bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead + if TOOLS[i].sFamily == 'MORTISE' then + if ToolSearchParameters.bAllowTopHead and not ToolSearchParameters.bAllowBottomHead then + bIsToolCompatible = TOOLS[i].SetupInfo.bIsTopHead + elseif ToolSearchParameters.bAllowBottomHead and not ToolSearchParameters.bAllowTopHead then + bIsToolCompatible = TOOLS[i].SetupInfo.bIsBottomHead + end end -- TODO nei confronti tra valori gestire tolleranze diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua index dd45245..b5fd50b 100644 --- a/Strategies/STR0003/STR0003.lua +++ b/Strategies/STR0003/STR0003.lua @@ -82,49 +82,49 @@ local function CalculateLeadInOut( Machining, EdgeToMachine) local LeadIn = {} local LeadOut = {} - LeadIn.StartAddLength = 0 - LeadOut.EndAddLength = 0 + LeadIn.dStartAddLength = 0 + LeadOut.dEndAddLength = 0 if not bIsMortising then - LeadIn.Type = MCH_MILL_LI.LINEAR - LeadOut.Type = MCH_MILL_LI.LINEAR - LeadIn.TangentDistance = 0 - LeadOut.TangentDistance = 0 + LeadIn.nType = MCH_MILL_LI.LINEAR + LeadOut.nType = MCH_MILL_LI.LINEAR + LeadIn.dTangentDistance = 0 + LeadOut.dTangentDistance = 0 if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then - LeadIn.PerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC - LeadOut.PerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC + LeadIn.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC + LeadOut.dPerpDistance = EdgeToMachine.dElevation + BeamData.CUT_SIC else - LeadIn.PerpDistance = BeamData.CUT_SIC - LeadOut.PerpDistance = BeamData.CUT_SIC + LeadIn.dPerpDistance = BeamData.CUT_SIC + LeadOut.dPerpDistance = BeamData.CUT_SIC end - LeadIn.Elevation = 0 - LeadOut.Elevation = 0 - LeadIn.CompLength = 0 - LeadOut.CompLength = 0 + LeadIn.dElevation = 0 + LeadOut.dElevation = 0 + LeadIn.dCompLength = 0 + LeadOut.dCompLength = 0 if Machining.bIsStartClosed and Machining.bIsEndClosed then - LeadIn.StartAddLength = -dAddLengthToReduce - LeadOut.EndAddLength = -dAddLengthToReduce + LeadIn.dStartAddLength = -dAddLengthToReduce + LeadOut.dEndAddLength = -dAddLengthToReduce elseif Machining.bIsStartClosed then - LeadIn.StartAddLength = -dAddLengthToReduce + LeadIn.dStartAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadOut.EndAddLength = max( -LeadIn.StartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + LeadOut.dEndAddLength = max( -LeadIn.dStartAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) elseif Machining.bIsEndClosed then - LeadOut.EndAddLength = -dAddLengthToReduce + LeadOut.dEndAddLength = -dAddLengthToReduce -- eventuale correzione per accorciamento maggiore di larghezza tasca - LeadIn.StartAddLength = max( -LeadOut.EndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) + LeadIn.dStartAddLength = max( -LeadOut.dEndAddLength - EdgeToMachine.dLength + 10 * BeamData.CUT_EXTRA, BeamData.CUT_EXTRA) else - LeadIn.StartAddLength = BeamData.CUT_EXTRA - LeadOut.EndAddLength = BeamData.CUT_EXTRA + LeadIn.dStartAddLength = BeamData.CUT_EXTRA + LeadOut.dEndAddLength = BeamData.CUT_EXTRA end else if Machining.bIsStartClosed then - LeadIn.StartAddLength = -dAddLengthToReduce + LeadIn.dStartAddLength = -dAddLengthToReduce else - LeadIn.StartAddLength = BeamData.CUT_EXTRA + LeadIn.dStartAddLength = BeamData.CUT_EXTRA end if Machining.bIsEndClosed then - LeadOut.EndAddLength = -dAddLengthToReduce + LeadOut.dEndAddLength = -dAddLengthToReduce else - LeadOut.EndAddLength = BeamData.CUT_EXTRA + LeadOut.dEndAddLength = BeamData.CUT_EXTRA end end @@ -322,7 +322,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.dRadialOffset = EdgeToMachine.dElevation end else - Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].MaxDepth - 1 + Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine else From b2a8279eb59fa91183a6a511706bdcc647e035df Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 28 May 2024 13:07:16 +0200 Subject: [PATCH 5/5] - in STR0003 modifiche per contemplare la restituzione dei risultati del calcolo al di fuori della strategia --- Strategies/STR0002/STR0002.lua | 2 +- Strategies/STR0003/STR0003.lua | 127 +++++++++++++++++---------------- 2 files changed, 66 insertions(+), 63 deletions(-) diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index ddacda4..7dfb309 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -99,7 +99,7 @@ function STR0002.Make( bAddMachining, Proc, Part, CustomParameters) local dNewRest = Proc.b3Box:getDimX() -- creo primo spezzone sulla sinistra if bStartLeft then - local AddId = EgtCopyGlob( Proc.iod, nAddGrpId) or GDB_ID.NULL + local AddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL dNewMinX = max( ( Proc.b3Box:getMin():getX() + TOOLS[ToolInfo.nToolIndex].dDiameter * 2), Part.b3Solid:getMin():getX() + BeamData.LONGCUT_ENDLEN) local ptOn = Point3d( dNewMinX, 0, 0) dNewRest = abs( dNewMaxX - dNewMinX) diff --git a/Strategies/STR0003/STR0003.lua b/Strategies/STR0003/STR0003.lua index b5fd50b..d11ce45 100644 --- a/Strategies/STR0003/STR0003.lua +++ b/Strategies/STR0003/STR0003.lua @@ -243,6 +243,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.bCanApply = true Cutting.sMessage = '' Cutting.idProc = Proc.id + local dResidualDepth = 0 local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then @@ -269,7 +270,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - saw blade not found' Cutting.bCanApply = false EgtOutLog( Cutting.sMessage) - return Cutting + return Cutting, EdgeToMachine.dElevation end -- verifica dimensioni tasca compatibili @@ -278,7 +279,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade thickness' Cutting.bCanApply = false EgtOutLog( Cutting.sMessage) - return Cutting + return Cutting, EdgeToMachine.dElevation end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della lama la strategia non è applicabile @@ -286,7 +287,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) Cutting.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for saw blade diameter' Cutting.bCanApply = false EgtOutLog( Cutting.sMessage) - return Cutting + return Cutting, EdgeToMachine.dElevation end end @@ -323,6 +324,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) end else Cutting.dDepthToMachine = TOOLS[Cutting.nToolIndex].dMaxDepth - 1 + dResidualDepth = EdgeToMachine.dElevation - Cutting.dDepthToMachine if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then Cutting.dRadialOffset = EdgeToMachine.dElevation - Cutting.dDepthToMachine else @@ -387,7 +389,7 @@ function Blade.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachine) EgtOutLog( sDamageNextPieceMessage) end - return Cutting + return Cutting, dResidualDepth end @@ -420,9 +422,9 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.bCanApply = true Mortising.sMessage = '' Mortising.idProc = Proc.id - local bNeedToMachineOtherSide = false -- OneSide | OneSideAndExtend | BothSides | BothSidesAndExtend local sMortisingType + local dResidualDepth = 0 local dPocketHeight = 0 if Proc.Topology.sFamily == 'Tunnel' then @@ -478,7 +480,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - chainsaw not found' Mortising.bCanApply = false EgtOutLog( Mortising.sMessage) - return Mortising, false + return Mortising, EdgeToMachine.dElevation end -- verifica dimensioni tasca compatibili @@ -487,7 +489,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw thickness' Mortising.bCanApply = false EgtOutLog( Mortising.sMessage) - return Mortising, false + return Mortising, EdgeToMachine.dElevation end if #( Proc.MainFaces.SideFaces) > 1 then -- se tasca più stretta della sega a catena la strategia non è applicabile @@ -495,7 +497,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.sMessage = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not applicable - pocket too narrow for chainsaw width' Mortising.bCanApply = false EgtOutLog( Mortising.sMessage) - return Mortising, false + return Mortising, EdgeToMachine.dElevation end end @@ -519,10 +521,8 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) + TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN elseif sMortisingType == 'BothSides' then Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) / 2 - bNeedToMachineOtherSide = true elseif sMortisingType == 'BothSidesAndExtend' then Mortising.dDepthToMachine = abs( EdgeToMachine.dElevation) / 2 + TOOLS[Mortising.nToolIndex].dCornerRadius + BeamData.CUT_EXTRA_MIN - bNeedToMachineOtherSide = true end if TOOLS[Mortising.nToolIndex].dMaxMat > Mortising.dDepthToMachine - 10 * GEO.EPS_SMALL then if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then @@ -532,6 +532,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi end else Mortising.dDepthToMachine = TOOLS[Mortising.nToolIndex].dMaxMat - 1 + dResidualDepth = EdgeToMachine.dElevation - Mortising.dDepthToMachine if EdgeToMachine.dElevation > -10 * GEO.EPS_SMALL then Mortising.dLongitudinalOffset = EdgeToMachine.dElevation - Mortising.dDepthToMachine else @@ -583,7 +584,7 @@ function Chainsaw.CalculateMachiningParameters( Proc, FaceToMachine, EdgeToMachi EgtOutLog( sDamageNextPieceMessage) end - return Mortising, bNeedToMachineOtherSide + return Mortising, dResidualDepth end @@ -607,25 +608,19 @@ 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') Strategy.sName = StrategyLib.Config.sStrategyId CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) - Strategy.RatingResult = {} - - Strategy.Saw = {} - Strategy.Chainsaw = {} + Strategy.Result = {} + Blade.Result = {} + Chainsaw.Result = {} local b3Raw = EgtGetRawPartBBox( Part.idRaw) - - -- TODO implementare gestione lapjoint lunghe - if Proc.IsSplittedLapJoint then - local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented for long lapjoint' - EgtOutLog( sErr) - return false, sErr - end + local dResidualDepth = 0 if not IsTopologyOk( Proc) then local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.sName .. ' not implemented' @@ -643,53 +638,53 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- lama -- lavorazione di lama - fondo della tasca o fino a massimo materiale se tunnel + table.insert( Blade.Result, {}) local Cutting = {} if Proc.Topology.sFamily == 'Tunnel' then - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) + Cutting, dResidualDepth = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) + Blade.Result[#Blade.Result].sType = 'Tunnel' else - Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge) + Cutting, dResidualDepth = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge) + Blade.Result[#Blade.Result].sType = 'Bottom' end - local bIsCuttingOk = false - if bAddMachining and Cutting.CanApply then - bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) + Blade.Result[#Blade.Result].bCanApply = Cutting.bCanApply + Blade.Result[#Blade.Result].sMessage = Cutting.sMessage + if bAddMachining and Cutting.bCanApply then + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) end - if not bIsCuttingOk then - return bIsCuttingOk, Cutting.Message - end - local dBottomDepthToMachine = Cutting.RadialOffset + local dBottomDepthToMachine = dResidualDepth -- lato opposto del tunnel if Proc.Topology.sFamily == 'Tunnel' then + table.insert( Blade.Result, {}) Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2]) - bIsCuttingOk = false - if bAddMachining and Cutting.CanApply then - bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) - end - if not bIsCuttingOk then - return bIsCuttingOk, Cutting.Message + Blade.Result[#Blade.Result].sType = 'Tunnel' + Blade.Result[#Blade.Result].bCanApply = Cutting.bCanApply + Blade.Result[#Blade.Result].sMessage = Cutting.sMessage + if bAddMachining and Cutting.bCanApply then + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) end else -- se la lama non è arrivata sul fondo e c'è almeno un lato aperto va lavorato - if Cutting.RadialOffset > 10 * GEO.EPS_SMALL then + if dResidualDepth > 10 * GEO.EPS_SMALL then + table.insert( Blade.Result, {}) -- eventuale lavorazione di lama - lato della tasca da cui inizia la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsStartOpen then Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1]) - bIsCuttingOk = false - if bAddMachining and Cutting.CanApply then - bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) - end - if not bIsCuttingOk then - return bIsCuttingOk, Cutting.Message + Blade.Result[#Blade.Result].sType = 'Side' + Blade.Result[#Blade.Result].bCanApply = Cutting.bCanApply + Blade.Result[#Blade.Result].sMessage = Cutting.sMessage + if bAddMachining and Cutting.bCanApply then + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) end end -- eventuale lavorazione di lama - lato della tasca in cui finisce la lavorazione if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsEndOpen then Cutting = Blade.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces, Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[2]) - bIsCuttingOk = false - if bAddMachining and Cutting.CanApply then - bIsCuttingOk, Cutting.Message = Blade.ApplyAllSteps( Cutting, b3Raw) - end - if not bIsCuttingOk then - return bIsCuttingOk, Cutting.Message + Blade.Result[#Blade.Result].sType = 'Side' + Blade.Result[#Blade.Result].bCanApply = Cutting.bCanApply + Blade.Result[#Blade.Result].sMessage = Cutting.sMessage + if bAddMachining and Cutting.bCanApply then + Blade.Result[#Blade.Result].bIsApplyOk, Blade.Result[#Blade.Result].sApplyMessage = Blade.AddMachiningAllSteps( Cutting, b3Raw) end end -- la lama è arrivata sul fondo e tasca passante, non servono ulteriori lavorazioni @@ -699,30 +694,38 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) end if Strategy.Parameters.bApplyOnlyBlade then - return bIsCuttingOk, Cutting.Message + -- TODO da rivedere + Strategy.Result.sInfo = Cutting.Message + Strategy.Result.bIsApplyOk = true + if dResidualDepth > 10 * GEO.EPS_SMALL then + Strategy.Result.sStatus = 'Not-Completed' + else + Strategy.Result.sStatus = 'Completed' + end + return Strategy.Result end -- sega a catena -- parametri lavorazione con sega a catena - fondo della tasca o tunnel local Mortising = {} - local bNeedToMachineOtherSide = false + local dResidualDepth = 0 if Proc.Topology == 'Tunnel' then - Mortising, bNeedToMachineOtherSide = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) + Mortising, dResidualDepth = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[1]) else Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge) -- si lavora solo quanto non lavorato dalla lama Mortising.MaxElev = dBottomDepthToMachine + BeamData.CUT_EXTRA end local bIsMortisingOk = false - if bAddMachining and Mortising.CanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + if bAddMachining and Mortising.bCanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) end -- lato opposto del tunnel - if Proc.Topology == 'Tunnel' and bNeedToMachineOtherSide then + if Proc.Topology == 'Tunnel' and ( dResidualDepth > 10 * GEO.EPS_SMALL) then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.OppositeEdges[2]) bIsMortisingOk = false - if bAddMachining and Mortising.CanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + if bAddMachining and Mortising.bCanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message @@ -734,8 +737,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFaces[1].MainEdges.BottomEdge.IsStartOpen then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].MainEdges.SideEdges[1]) bIsMortisingOk = false - if bAddMachining and Mortising.CanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + if bAddMachining and Mortising.bCanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message @@ -745,8 +748,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) if Proc.MainFaces.LongFace[1].MainEdges.BottomEdge.IsEndOpen then Mortising = Chainsaw.CalculateMachiningParameters( Proc, Proc.MainFaces.LongFaces[1], Proc.MainFaces.LongFaces[1].Edges.SideEdges[2]) bIsMortisingOk = false - if bAddMachining and Mortising.CanApply then - bIsMortisingOk, Mortising.Message = Chainsaw.ApplyAllSteps( Mortising, b3Raw) + if bAddMachining and Mortising.bCanApply then + bIsMortisingOk, Mortising.Message = Chainsaw.AddMachiningAllSteps( Mortising, b3Raw) end if not bIsMortisingOk then return bIsMortisingOk, Mortising.Message