diff --git a/LuaLibs/BasicCustomerStrategies.lua b/LuaLibs/BasicCustomerStrategies.lua index 66aea4b..01729bd 100644 --- a/LuaLibs/BasicCustomerStrategies.lua +++ b/LuaLibs/BasicCustomerStrategies.lua @@ -25,12 +25,12 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Cut if ID.IsHeadCut( Proc) then -- TODO TOGLIERE IL true PER FORZARE IF!!! PROVVISORIO PER PROVARE STRATEGIE - if Proc.Topology.Name == 'FEATURE' then + if Proc.Topology.sName == 'FEATURE' then Strategy_Egalware = { - StrategyId = 'STR0001', + sStrategyId = 'STR0001', Parameters = { - { Name = 'Step', Value = '15', Type = 'd'}, - { Name = 'AntiSplint', Value = 'false', Type = 'b'} + { sName = 'Step', sValue = '15', sType = 'd'}, + { sName = 'AntiSplint', sValue = 'false', sType = 'b'} } } table.insert( Strategies_Egalware, Strategy_Egalware) @@ -57,8 +57,8 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Slot elseif ID.IsSlot( Proc) then - if Proc.Topology.Name == 'Pocket-5-Blind' then - Strategy_Egalware = { StrategyId = 'STR0002'} + if Proc.Topology.sName == 'Pocket-5-Blind' then + Strategy_Egalware = { sStrategyId = 'STR0002'} table.insert( Strategies_Egalware, Strategy_Egalware) Strategy_Egalware = {} end @@ -101,8 +101,8 @@ local function GetStrategies_Egalware( Proc) --------------------------------------------------------------------- -- Feature : Pocket elseif ID.IsPocket( Proc) then - if Proc.Topology.Name == 'Pocket-5-Blind' then - Strategy_Egalware = { StrategyId = 'STR0002'} + if Proc.Topology.sName == 'Pocket-5-Blind' then + Strategy_Egalware = { sStrategyId = 'STR0002'} table.insert( Strategies_Egalware, Strategy_Egalware) Strategy_Egalware = {} end @@ -235,8 +235,8 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Slot elseif ID.IsSlot( Proc) then - if Proc.Topology.Name == 'Pocket-5-Blind' then - Strategy_Essetre = { StrategyId = 'STR0002'} + if Proc.Topology.sName == 'Pocket-5-Blind' then + Strategy_Essetre = { sStrategyId = 'STR0002'} table.insert( Strategies_Essetre, Strategy_Essetre) Strategy_Essetre = {} end @@ -279,8 +279,8 @@ local function GetStrategies_Essetre( Proc) --------------------------------------------------------------------- -- Feature : Pocket elseif ID.IsPocket( Proc) then - if Proc.Topology.Name == 'Pocket-5-Blind' then - Strategy_Essetre = { StrategyId = 'STR0002'} + if Proc.Topology.sName == 'Pocket-5-Blind' then + Strategy_Essetre = { sStrategyId = 'STR0002'} table.insert( Strategies_Essetre, Strategy_Essetre) Strategy_Essetre = {} end diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index e4e522b..341105e 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -63,13 +63,13 @@ end ------------------------------------------------------------------------------------------------------------- local function IsToolOk( Tool) -- controllo che i dati necessari siano impostati - if Tool.MaxMaterial and Tool.Diameter and Tool.Length and Tool.Head and Tool.UUID then + if Tool.dMaxMaterial and Tool.dDiameter and Tool.dLength and Tool.sHead and Tool.sUUID then -- se DRILLBIT non ho altri dati - if Tool.Family == 'DRILLBIT' then + if Tool.sFamily == 'DRILLBIT' then return true -- altrimenti controllo dati aggiuntivi altre famiglie di utensili else - if Tool.Thick then + if Tool.dThick then return true end end @@ -86,13 +86,13 @@ function BeamExec.GetToolsFromDB() local Tool = {} -- recupero tutti gli utensili : punte a forare, lame, frese e motoseghe - Tool.Name = EgtTdbGetFirstTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) - while Tool.Name ~= '' do + Tool.sName = EgtTdbGetFirstTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) + while Tool.sName ~= '' do -- imposto utensile come corrente per recuperarne i dati - EgtTdbSetCurrTool( Tool.Name) + EgtTdbSetCurrTool( Tool.sName) -- verifico se utensile disponibile in attrezzaggio attuale e che abbia un tipo ben definito - local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.Name) + local bToolLoadedOnSetup, sToolTCPos = EgtFindToolInCurrSetup( Tool.sName) local dToolTypeID = EgtTdbGetCurrToolParam( MCH_TP.TYPE) local sToolType, sToolFamily = GetToolTypeNameFromToolTypeID( dToolTypeID) @@ -100,60 +100,60 @@ function BeamExec.GetToolsFromDB() if bToolLoadedOnSetup and sToolType then -- TODO Tool.AName -> da rimuovere perchè non serve. Per il momento lo manteniamo solo perchè è più facile vedere e interpretare la lista utensili nella watch di zerobrane -- Nell'utilizzo, si legge sempre il Tool.Name - Tool.AName = Tool.Name - Tool.TcPos = sToolTCPos - Tool.Family = sToolFamily - Tool.Type = sToolType - Tool.TypeID = dToolTypeID - Tool.MaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) - Tool.Diameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) - Tool.Length = EgtTdbGetCurrToolParam( MCH_TP.LEN) - Tool.Speed = EgtTdbGetCurrToolParam( MCH_TP.SPEED) - Tool.IsCCW = Tool.Speed < 0 + Tool.AName = Tool.sName + Tool.sTcPos = sToolTCPos + Tool.sFamily = sToolFamily + Tool.sType = sToolType + Tool.dTypeID = dToolTypeID + Tool.dMaxMaterial = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + Tool.dDiameter = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + Tool.dLength = EgtTdbGetCurrToolParam( MCH_TP.LEN) + Tool.dSpeed = EgtTdbGetCurrToolParam( MCH_TP.SPEED) + Tool.bIsCCW = Tool.dSpeed < 0 Tool.Feeds = {} - Tool.Feeds.Feed = EgtTdbGetCurrToolParam( MCH_TP.FEED) - Tool.Feeds.StartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED) - Tool.Feeds.EndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) - Tool.Feeds.TipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) + Tool.Feeds.dFeed = EgtTdbGetCurrToolParam( MCH_TP.FEED) + Tool.Feeds.dStartFeed = EgtTdbGetCurrToolParam( MCH_TP.STARTFEED) + Tool.Feeds.dEndFeed = EgtTdbGetCurrToolParam( MCH_TP.ENDFEED) + Tool.Feeds.dTipFeed = EgtTdbGetCurrToolParam( MCH_TP.TIPFEED) -- TODO serve funzione in BeamData che data la posizione dell'utensile e della testa, capisca il montaggio (testa sopra - testa sotto - aggregato - ecc...) - Tool.Head = EgtTdbGetCurrToolParam( MCH_TP.HEAD) - Tool.UUID = EgtTdbGetCurrToolParam( MCH_TP.UUID) - Tool.UserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES) - Tool.MaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.MaxMaterial + Tool.sHead = EgtTdbGetCurrToolParam( MCH_TP.HEAD) + Tool.sUUID = EgtTdbGetCurrToolParam( MCH_TP.UUID) + Tool.sUserNotes = EgtTdbGetCurrToolParam( MCH_TP.USERNOTES) + Tool.dMaxDepth = EgtTdbGetCurrToolMaxDepth() or Tool.dMaxMaterial Tool.ToolHolder = {} - Tool.ToolHolder.Diameter = EgtTdbGetCurrToolThDiam() or TH_DIAMETER_HSK63 -- diametro standard HSK63 - Tool.ToolHolder.Length = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63 + Tool.ToolHolder.dDiameter = EgtTdbGetCurrToolThDiam() or TH_DIAMETER_HSK63 -- diametro standard HSK63 + Tool.ToolHolder.dLength = EgtTdbGetCurrToolThLength() or TH_LENGTH_HSK63 -- lunghezza standard HSK63 -- parametri scritti nelle note - Tool.Double = EgtGetValInNotes( Tool.UserNotes, 'DOUBLE') + Tool.nDouble = EgtGetValInNotes( Tool.sUserNotes, 'DOUBLE') -- lettura parametri non comuni ( famiglia DRILLBIT non ha parametri specifici) if sToolFamily ~= 'DRILLBIT' then - Tool.Thick = EgtTdbGetCurrToolParam( MCH_TP.THICK) - Tool.LongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET) - Tool.RadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET) + Tool.dThick = EgtTdbGetCurrToolParam( MCH_TP.THICK) + Tool.dLongitudinalOffset = EgtTdbGetCurrToolParam( MCH_TP.LONOFFSET) + Tool.dRadialOffset = EgtTdbGetCurrToolParam( MCH_TP.RADOFFSET) -- recupero parametri propri delle frese if sToolFamily == 'MILL' then - Tool.StemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ThDiameter -- se non settato, considero diametro come ToolHolder - Tool.SideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0 + Tool.dStemDiameter = EgtTdbGetCurrToolParam( MCH_TP.STEMDIAM) or Tool.ToolHolder.dDiameter -- se non settato, considero diametro come ToolHolder + Tool.dSideAngle = EgtTdbGetCurrToolParam( MCH_TP.SIDEANG) or 0 -- verifico che parametri siano compatibili con una fresa a coda di rondine ( angolo di fianco standard Coda di rondine -> 15°) - Tool.IsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.SideAngle) - SIDEANGLE_DOVETAIL) < 1 + Tool.bIsDoveTail = Tool.Type == 'MILL_NOTIP' and abs( abs( Tool.dSideAngle) - SIDEANGLE_DOVETAIL) < 1 -- verifico che sia una fresa tipo T-Mill o BlockHaus - Tool.SideDepth = EgtGetValInNotes( Tool.UserNotes, 'SIDEDEPTH') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale - Tool.IsTMill = Tool.SideDepth > 0 - Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or ( Tool.MaxMaterial / 2) -- se non settato nell'utensile, considero metà del tagliente - Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.Diameter / 2) -- se non settato nell'utensile, considero metà del diametro + Tool.dSideDepth = EgtGetValInNotes( Tool.sUserNotes, 'SIDEDEPTH') or 0 -- se non settato nell'utensile, dico che non ha massimo affondamento laterale + Tool.bIsTMill = Tool.dSideDepth > 0 + Tool.dStep = EgtGetValInNotes( Tool.sUserNotes, 'STEP') or ( Tool.dMaxMaterial / 2) -- se non settato nell'utensile, considero metà del tagliente + Tool.dSideStep = EgtGetValInNotes( Tool.sUserNotes, 'SIDESTEP') or floor( Tool.dDiameter / 2) -- se non settato nell'utensile, considero metà del diametro -- recupero parametri propri delle lame elseif sToolFamily == 'SAWBLADE' then - Tool.IsUsedForLongCut = EgtGetValInNotes( Tool.UserNotes, 'LONGCUT') == 1 or false -- false coem valore di default - Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or Tool.Thick -- se non settato nell'utensile, considero lo spessore lama - Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.Diameter / 4) -- se non settato nell'utensile, considero un quarto del diametro + 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.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 - Tool.Distance = EgtTdbGetCurrToolParam( MCH_TP.DIST) or 90 -- 90mm dimensione standard aggregato catena - Tool.IsMortise = EgtGetValInNotes( Tool.UserNotes, 'MORTISE') == 1 - Tool.IsChainSaw = not Tool.IsMortise - Tool.Step = EgtGetValInNotes( Tool.UserNotes, 'STEP') or ( Tool.Thick - 1) -- se non settato nell'utensile, considero spessore catena meno 1mm di sicurezza - Tool.SideStep = EgtGetValInNotes( Tool.UserNotes, 'SIDESTEP') or floor( Tool.MaxMaterial / 3) -- se non settato nell'utensile, considero un terzo della lunghezza + 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 end end @@ -162,7 +162,7 @@ function BeamExec.GetToolsFromDB() table.insert( TOOLS, Tool) -- altrimenti scrivo nel log che l'utensile non è conforme else - EgtOutLog( '*** ' .. Tool.Name .. ' : NOT-COMPLIANT ***', 1) + EgtOutLog( '*** ' .. Tool.sName .. ' : NOT-COMPLIANT ***', 1) end -- reset dati @@ -170,7 +170,7 @@ function BeamExec.GetToolsFromDB() end -- recupero utensile successivo ( punte a forare, lame, frese e motoseghe) - Tool.Name = EgtTdbGetNextTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) + Tool.sName = EgtTdbGetNextTool( MCH_TF.DRILLBIT + MCH_TF.SAWBLADE + MCH_TF.MILL + MCH_TF.MORTISE) end end @@ -228,8 +228,8 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b -- Creazione nuovo gruppo di lavoro if not bMachGroupOk then local sMgName = EgtGetMachGroupNewName( 'Mach_1') - local NewMgId = EgtAddMachGroup( sMgName) - if not NewMgId then + local idNewMg = EgtAddMachGroup( sMgName) + if not idNewMg then local sOut = 'Errore nella creazione del gruppo di lavoro ' .. sMgName return false, sOut end @@ -251,110 +251,110 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, vBeam, b local b3Tab = EgtGetTableArea() -- Calcolo posizione estremo TR/BR della tavola rispetto a sua origine in BL local dPosY = EgtIf( BeamData.CENTER_BEAM, ( b3Tab:getDimY() + dRawW * EgtIf( BeamData.RIGHT_LOAD, -1, 1)) / 2, EgtIf( BeamData.RIGHT_LOAD, 0, b3Tab:getDimY())) - BeamData.OriXR = Point3d( b3Tab:getDimX(), dPosY, 0) - BeamData.PosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) + BeamData.ptOriXR = Point3d( b3Tab:getDimX(), dPosY, 0) + BeamData.dPosXR = EgtIf( BeamData.RIGHT_LOAD, MCH_CR.BR, MCH_CR.TR) -- Impostazione dell'attrezzaggio di default EgtImportSetup() -- Inserimento dei pezzi con il loro grezzo - local Cnt = 0 - local Len = dRawL - local nPrevRaw, dPrevDelta - local DeltaS = dOvmHead - local DeltaSMin = 0 - local DeltaE = BeamData.OVM_MID + local nCnt = 0 + local dLen = dRawL + local idPrevRaw, dPrevDelta + local dDeltaS = dOvmHead + local dDeltaSMin = 0 + local dDeltaE = BeamData.OVM_MID for i = 1, #vBeam do -- assegno identificativo pezzo - local Pz = vBeam[i].Id + local idPz = vBeam[i].Id -- dati del pezzo - local b3Part = EgtGetBBoxGlob( Pz or GDB_ID.NULL, GDB_BB.EXACT) - local b3Solid = vBeam[i].Box + local b3Part = EgtGetBBoxGlob( idPz or GDB_ID.NULL, GDB_BB.EXACT) + local b3Solid = vBeam[i].b3Box if b3Part:isEmpty() or b3Solid:isEmpty() then break end EgtOutLog( 'PartSez=' .. EgtNumToString( b3Part:getDimY(), 1) .. 'x' .. EgtNumToString( b3Part:getDimZ(), 1), 3) -- se sezione compatibile e lunghezza disponibile sufficiente - local PartLen = b3Solid:getDimX() - local PartWidth = b3Solid:getDimY() - local PartHeight = b3Solid:getDimZ() - local NextLen = Len - DeltaS - PartLen - DeltaE - if (( abs( PartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( PartHeight - dRawH) < 100 * GEO.EPS_SMALL) or - ( abs( PartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( PartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and - NextLen + DeltaE >= 0 then + local dPartLen = b3Solid:getDimX() + local dPartWidth = b3Solid:getDimY() + local dPartHeight = b3Solid:getDimZ() + local dNextLen = dLen - dDeltaS - dPartLen - dDeltaE + if (( abs( dPartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartHeight - dRawH) < 100 * GEO.EPS_SMALL) or + ( abs( dPartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and + dNextLen + dDeltaE >= 0 then -- eventuale sovramateriale di testa if i > 1 then - if vBeam[i].PosX then - DeltaS = max( vBeam[i].PosX - ( dRawL - Len), DeltaSMin) + if vBeam[i].dPosX then + dDeltaS = max( vBeam[i].dPosX - ( dRawL - dLen), dDeltaSMin) else - DeltaS = max( dOvmMid - DeltaE, 0) + dDeltaS = max( dOvmMid - dDeltaE, 0) end end -- dimensioni del grezzo - local CrawLen = min( PartLen + DeltaS + DeltaE, Len) - local Delta = CrawLen - PartLen - DeltaS + local dCrawLen = min( dPartLen + dDeltaS + dDeltaE, dLen) + local dDelta = dCrawLen - dPartLen - dDeltaS -- creo e posiziono il grezzo - local nRaw = EgtAddRawPart( Point3d(0,0,0), CrawLen, dRawW, dRawH, BeamData.RAWCOL) - EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR) - EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0)) + local idRaw = EgtAddRawPart( Point3d(0,0,0), dCrawLen, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( idRaw, BeamData.ptOriXR, BeamData.dPosXR) + EgtMoveRawPart( idRaw, Vector3d( dLen - dRawL, 0, 0)) -- assegno ordine in lavorazione - Cnt = Cnt + 1 - EgtSetInfo( nRaw, 'ORD', Cnt) + nCnt = nCnt + 1 + EgtSetInfo( idRaw, 'ORD', nCnt) -- creo o pulisco gruppo geometrie aggiuntive - if not BeamLib.CreateOrEmptyAddGroup( Pz) then - local sOut = 'Error creating Additional Group in Part ' .. tostring( Pz) + if not BeamLib.CreateOrEmptyAddGroup( idPz) then + local sOut = 'Error creating Additional Group in Part ' .. tostring( idPz) return false, sOut end -- aggiungo faccia per taglio iniziale al pezzo - BeamLib.AddPartStartFace( Pz, b3Solid) + BeamLib.AddPartStartFace( idPz, b3Solid) -- se sovramateriale di testa, lo notifico - if DeltaS > 0.09 then - EgtSetInfo( nRaw, 'HOVM', DeltaS) - if nPrevRaw then - EgtSetInfo( nPrevRaw, 'BDST', DeltaS + dPrevDelta) + if dDeltaS > 0.09 then + EgtSetInfo( idRaw, 'HOVM', dDeltaS) + if idPrevRaw then + EgtSetInfo( idPrevRaw, 'BDST', dDeltaS + dPrevDelta) end end - if DeltaE > 0.09 then - EgtSetInfo( nRaw, 'TOVM', DeltaE) + if dDeltaE > 0.09 then + EgtSetInfo( idRaw, 'TOVM', dDeltaE) end -- aggiungo faccia per taglio finale al pezzo - BeamLib.AddPartEndFace( Pz, b3Solid) + BeamLib.AddPartEndFace( idPz, b3Solid) -- inserisco il pezzo nel grezzo - EgtDeselectPartObjs( Pz) - local ptPos = b3Part:getMin() - b3Solid:getMin() + Vector3d( Delta, ( dRawW - PartWidth) / 2, ( dRawH - PartHeight) / 2) - EgtAddPartToRawPart( Pz, ptPos, nRaw) - if abs( PartWidth - dRawW) > 100 * GEO.EPS_SMALL then + EgtDeselectPartObjs( idPz) + local ptPos = b3Part:getMin() - b3Solid:getMin() + Vector3d( dDelta, ( dRawW - dPartWidth) / 2, ( dRawH - dPartHeight) / 2) + EgtAddPartToRawPart( idPz, ptPos, idRaw) + if abs( dPartWidth - dRawW) > 100 * GEO.EPS_SMALL then -- rotazione attorno a centro geometria complessiva del pezzo - EgtRotatePartInRawPart( Pz, X_AX(), 90) + EgtRotatePartInRawPart( idPz, X_AX(), 90) -- correggo per eccentricità solido rispetto a geometria complessiva del pezzo local vtEccOri = b3Solid:getCenter() - b3Part:getCenter() local vtEccRot = Vector3d( vtEccOri) vtEccRot:rotate( X_AX(), 90) - EgtMovePartInRawPart( Pz, ( vtEccOri - vtEccRot)) + EgtMovePartInRawPart( idPz, ( vtEccOri - vtEccRot)) end -- aggiorno la lunghezza residua della barra - Len = Len - CrawLen + dLen = dLen - dCrawLen -- aggiorno grezzo precedente - nPrevRaw = nRaw - dPrevDelta = Delta + idPrevRaw = idRaw + dPrevDelta = dDelta else - local sOut = 'Error: part L(' .. EgtNumToString( PartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( Len - 0.1, 1) .. ')' + local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut end -- se rimasto troppo poco grezzo, esco --if Len < BeamData.MinRaw then break end DeltaS = 0 end - if nPrevRaw then - EgtSetInfo( nPrevRaw, 'BDST', 10000) + if idPrevRaw then + EgtSetInfo( idPrevRaw, 'BDST', 10000) end -- Se rimasto materiale aggiungo grezzo dell'avanzo - if Len > 10 then - local nRaw = EgtAddRawPart( Point3d(0,0,0), Len, dRawW, dRawH, BeamData.RAWCOL) - EgtMoveToCornerRawPart( nRaw, BeamData.OriXR, BeamData.PosXR) - EgtMoveRawPart( nRaw, Vector3d( Len - dRawL, 0, 0)) + if dLen > 10 then + local idRaw = EgtAddRawPart( Point3d(0,0,0), dLen, dRawW, dRawH, BeamData.RAWCOL) + EgtMoveToCornerRawPart( idRaw, BeamData.ptOriXR, BeamData.dPosXR) + EgtMoveRawPart( idRaw, Vector3d( dLen - dRawL, 0, 0)) -- assegno ordine in lavorazione - Cnt = Cnt + 1 - EgtSetInfo( nRaw, 'ORD', Cnt) + nCnt = nCnt + 1 + EgtSetInfo( idRaw, 'ORD', nCnt) end return true @@ -363,18 +363,18 @@ end ------------------------------------------------------------------------------------------------------------- function BeamExec.CalcMinUnloadableRaw( dRawW, dRawH) if BeamData.GetMinUnloadableRaw then - BeamData.MinRaw = BeamData.GetMinUnloadableRaw( dRawW, dRawH) + BeamData.dMinRaw = BeamData.GetMinUnloadableRaw( dRawW, dRawH) else local H_S = 200 local H_L = 400 -- Determinazione minimo grezzo scaricabile if dRawH <= H_S then - BeamData.MinRaw = BeamData.MINRAW_S + BeamData.dMinRaw = BeamData.MINRAW_S elseif dRawH <= H_L then local Coeff = ( dRawH - H_S) / ( H_L - H_S) - BeamData.MinRaw = ( 1 - Coeff) * BeamData.MINRAW_S + Coeff * BeamData.MINRAW_L + BeamData.dMinRaw = ( 1 - Coeff) * BeamData.MINRAW_S + Coeff * BeamData.MINRAW_L else - BeamData.MinRaw = BeamData.MINRAW_L + BeamData.dMinRaw = BeamData.MINRAW_L end end end @@ -387,11 +387,11 @@ local function GetStrategiesFromGlobalList( Proc) -- cerco tra le feature for i = 1, #STRATEGIES.Features do -- se trovo la feature - if Proc.Prc == STRATEGIES.Features[i].Prc and Proc.Grp == STRATEGIES.Features[i].Grp then + if Proc.nPrc == STRATEGIES.Features[i].nPrc and Proc.nGrp == STRATEGIES.Features[i].nGrp then -- cerco tra le topologie for j = 1, #STRATEGIES.Features[i].Topologies do -- se trovo la topologia - if Proc.Topology.Name == STRATEGIES.Features[i].Topologies[j].Name then + if Proc.Topology.sName == STRATEGIES.Features[i].Topologies[j].sName then -- ritorno le strategie disponibili per la feature che sto analizzando return STRATEGIES.Features[i].Topologies[j].Strategies end @@ -426,21 +426,21 @@ local function GetFeatureForcedStrategy( Proc) local StrategyData = require( sStrategyId .. '\\' .. sStrategyId .. 'Config') -- se ID strategia non esiste oppure ID letto in NGE è differente da quello letto nella strategia, esco subito - if not StrategyData or StrategyData.StrategyId ~= sStrategyId then + if not StrategyData or StrategyData.sStrategyId ~= sStrategyId then return nil end -- salvo che questa strategia è stata forzata, e che quindi ho già letto il file config con i parametri di default -- quando si calcolerà la lavorazione non servirà leggere/riverificare i parametri di default - StrategyData.ForcedStrategy = true + StrategyData.bForcedStrategy = true -- cerco e aggiorno i parametri come sono settati nel processing for i = 1, #StrategyData.Parameters do - local sParameterToRead = StrategyData.StrategyId .. '_' .. StrategyData.Parameters[i].Name + local sParameterToRead = StrategyData.sStrategyId .. '_' .. StrategyData.Parameters[i].sName ForcedParameterForProc = EgtGetInfo( Proc.Id, sParameterToRead, 's') -- se ho trovato il valore, lo sovrascrivo al default if ForcedParameterForProc then - StrategyData.Parameters[i].Value = ForcedParameterForProc + StrategyData.Parameters[i].sValue = ForcedParameterForProc end end @@ -470,25 +470,25 @@ local function CollectFeatures( PartId, Part) local nDo = EgtGetInfo( ProcId, 'DO', 'i') or 1 if nGrp and nPrc and nDo == 1 then local Proc = {} - Proc.PartId = PartId + Proc.idPart = PartId Proc.Id = ProcId -- id della feature btl ( se non presente info, si prende id dell'entità geometrica) - Proc.FeatureId = EgtGetInfo( Proc.Id, 'PRID', 's') or Proc.Id - Proc.Grp = nGrp - Proc.Prc = nPrc - Proc.Flg = 1 - Proc.Fct = EgtSurfTmFacetCount( ProcId) or 0 - Proc.CutId = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0 - Proc.TaskId = EgtGetInfo( ProcId, 'TASKID', 'i') or 0 - Proc.Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) - EgtOutLog( '------Feature ' .. Proc.FeatureId .. '------') + Proc.idFeature = EgtGetInfo( Proc.Id, 'PRID', 's') or Proc.Id + Proc.nGrp = nGrp + Proc.nPrc = nPrc + Proc.nFlg = 1 + Proc.nFct = EgtSurfTmFacetCount( ProcId) or 0 + Proc.idCut = EgtGetInfo( EgtGetParent( EgtGetParent( ProcId)), 'CUTID', 'i') or 0 + Proc.idTask = EgtGetInfo( ProcId, 'TASKID', 'i') or 0 + Proc.b3Box = EgtGetBBoxGlob( ProcId, GDB_BB.STANDARD) + EgtOutLog( '------Feature ' .. Proc.idFeature .. '------') -- se esiste la geometria - if Proc.Box and not Proc.Box:isEmpty() then + if Proc.b3Box and not Proc.b3Box:isEmpty() then -- TODO fare una funzione per recuperare i dati delle feature che non passano dal calcolo della topologia? -- se foro calcolo altri dati if ID.IsDrilling( Proc) then -- assegno diametro e facce di ingresso e uscita (dati tabelle sempre per riferimento) - Proc.Diam, Proc.Len, Proc.Fcs, Proc.Fce = FeatureData.GetDrillingData( Proc) + Proc.dDiam, Proc.dLen, Proc.nFcs, Proc.nFce = FeatureData.GetDrillingData( Proc) end -- informazioni facce e topologia Proc.AffectedFaces = BeamLib.GetAffectedFaces( Proc) @@ -499,11 +499,11 @@ local function CollectFeatures( PartId, Part) Proc.Faces = FaceData.GetFacesInfo( Proc, Part) Proc.Topology = FeatureData.ClassifyTopology( Proc, Part) else - Proc.Topology.Family = 'FEATURE' - Proc.Topology.Name = 'FEATURE' + Proc.Topology.sFamily = 'FEATURE' + Proc.Topology.sName = 'FEATURE' end -- se topologia feature riconosciuta, oppure da non calcolare perchè il riconoscimento topologico è basato sulla feature stessa - if Proc.Topology.Name ~= 'NOT_IMPLEMENTED' then + if Proc.Topology.sName ~= 'NOT_IMPLEMENTED' then -- TODO Funzione 'GetMainFaces' da scrivere Proc.MainFaces = FaceData.GetMainFaces( Proc) -- se la processing ha una strategia forzata, riporto tutto nella proc @@ -519,16 +519,16 @@ local function CollectFeatures( PartId, Part) table.insert( vProc, Proc) -- altrimenti errore (non ci sono strategie per lavorare la topologia riconosciuta) else - EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' : NO available strategies') + EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') end -- altrimenti errore (serviva riconoscimento topologico, ma non è stato possibile farlo) else - EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' : NO available strategies') + EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' : NO available strategies') end else Proc.Flg = 0 table.insert( vProc, Proc) - EgtOutLog( ' Feature ' .. tostring( Proc.FeatureId) .. ' is empty (no geometry)') + EgtOutLog( ' Feature ' .. tostring( Proc.idFeature) .. ' is empty (no geometry)') end end end @@ -577,16 +577,16 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part) -- centri allineati, equidistanti dalla mezzeria trave, non troppo vicini local vtDisplacement = ptBC - ptBCMirror - local ptCenRaw = Part.RawBox:getCenter() + local ptCenRaw = Part.b3RawBox:getCenter() if nDouble == 2 then - local dYMinDistance = max( Proc.Box:getMin():getY(), ProcMirror.Box:getMin():getY()) - min( Proc.Box:getMax():getY(), ProcMirror.Box:getMax():getY()) + local dYMinDistance = max( Proc.b3Box:getMin():getY(), ProcMirror.b3Box:getMin():getY()) - min( Proc.b3Box:getMax():getY(), ProcMirror.b3Box:getMax():getY()) if not ( abs( vtDisplacement:getX()) < 100 * GEO.EPS_SMALL and abs( vtDisplacement:getZ()) < 100 * GEO.EPS_SMALL and ( abs( ptBC:getY() - ptCenRaw:getY()) - abs( ptBCMirror:getY() - ptCenRaw:getY())) < 100 * GEO.EPS_SMALL and dYMinDistance > MIRROR_DRILLINGS_MIN_DISTANCE + 10 * GEO.EPS_SMALL) then return false end else - local dZMinDistance = max( Proc.Box:getMin():getZ(), ProcMirror.Box:getMin():getZ()) - min( Proc.Box:getMax():getZ(), ProcMirror.Box:getMax():getZ()) + local dZMinDistance = max( Proc.b3Box:getMin():getZ(), ProcMirror.b3Box:getMin():getZ()) - min( Proc.b3Box:getMax():getZ(), ProcMirror.b3Box:getMax():getZ()) if not ( abs( vtDisplacement:getX()) < 100 * GEO.EPS_SMALL and abs( vtDisplacement:getY()) < 100 * GEO.EPS_SMALL and ( abs( ptBC:getZ() - ptCenRaw:getZ()) - abs( ptBCMirror:getZ() - ptCenRaw:getZ())) < 100 * GEO.EPS_SMALL and dZMinDistance > MIRROR_DRILLINGS_MIN_DISTANCE + 10 * GEO.EPS_SMALL) then @@ -595,7 +595,7 @@ local function AreDrillingsMirrored( Proc, ProcMirror, Part) end -- fori della stessa profondità - if abs( Proc.Len - ProcMirror.Len) > 10 * GEO.EPS_SMALL then + if abs( Proc.dLen - ProcMirror.dLen) > 10 * GEO.EPS_SMALL then return false end @@ -613,9 +613,9 @@ local function GetFeatureInfoAndDependency( vProcSingleRot, Part) if i ~= j then local ProcB = vProcSingleRot[j] -- verifico se feature tipo LapJoint è attraversata da almeno un foro - if ( Proc.Topology.Family == 'Pocket' or Proc.Topology.Family == 'Tunnel' or Proc.Topology.Family == 'Groove' or ID.IsMortise( Proc)) and - ID.IsDrilling( ProcB) and Overlaps( Proc.Box, ProcB.Box) then - Proc.PassedByHole = true + if ( Proc.Topology.sFamily == 'Pocket' or Proc.Topology.sFamily == 'Tunnel' or Proc.Topology.sFamily == 'Groove' or ID.IsMortise( Proc)) and + ID.IsDrilling( ProcB) and Overlaps( Proc.b3Box, ProcB.b3Box) then + Proc.bPassedByHole = true end -- verifiche per specchiature if BeamData.DOWN_HEAD or BeamData.TWO_EQUAL_HEADS then @@ -658,28 +658,28 @@ local function GetIndexBestStrategyFromComparison( AvailableStrategies, nIndex1, dChosenIndex = 0 elseif nIndex1 == 0 then -- basta che sia applicabile - if AvailableStrategies[nIndex2].RatingResult and ( AvailableStrategies[nIndex2].RatingResult.Status == 'Completed' or AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Completed') then + if AvailableStrategies[nIndex2].RatingResult and ( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Completed' or AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Completed') then dChosenIndex = nIndex2 end elseif nIndex2 == 0 then -- basta che sia applicabile - if AvailableStrategies[nIndex1].RatingResult and ( AvailableStrategies[nIndex1].RatingResult.Status == 'Completed' or AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Completed') then + if AvailableStrategies[nIndex1].RatingResult and ( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Completed' or AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Completed') then dChosenIndex = nIndex1 end elseif not AvailableStrategies[nIndex1].RatingResult or not AvailableStrategies[nIndex2].RatingResult then dChosenIndex = 0 - elseif ( AvailableStrategies[nIndex1].RatingResult.Status == 'Completed' and AvailableStrategies[nIndex2].RatingResult.Status ~= 'Completed') or - ( AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Completed' and AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Applicable') then + elseif ( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Completed' and AvailableStrategies[nIndex2].RatingResult.sStatus ~= 'Completed') or + ( AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Completed' and AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Applicable') then dChosenIndex = nIndex1 - elseif ( AvailableStrategies[nIndex2].RatingResult.Status == 'Completed' and AvailableStrategies[nIndex1].RatingResult.Status ~= 'Completed') or - ( AvailableStrategies[nIndex2].RatingResult.Status == 'Not-Completed' and AvailableStrategies[nIndex1].RatingResult.Status == 'Not-Applicable') then + elseif ( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Completed' and AvailableStrategies[nIndex1].RatingResult.sStatus ~= 'Completed') or + ( AvailableStrategies[nIndex2].RatingResult.sStatus == 'Not-Completed' and AvailableStrategies[nIndex1].RatingResult.sStatus == 'Not-Applicable') then dChosenIndex = nIndex2 else -- se le due strategie hanno stesso stato e sono entrambe applicabili (quindi entrambe complete o entrambe non-complete) - if AvailableStrategies[nIndex1].RatingResult.Status ~= 'Not-Applicable' and AvailableStrategies[nIndex2].RatingResult.Status ~= 'Not-Applicable' and - AvailableStrategies[nIndex1].RatingResult.Status == AvailableStrategies[nIndex2].RatingResult.Status then - local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].RatingResult.Rating + AvailableStrategies[nIndex1].RatingResult.CompletionIndex - local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].RatingResult.Rating + AvailableStrategies[nIndex2].RatingResult.CompletionIndex + if AvailableStrategies[nIndex1].RatingResult.sStatus ~= 'Not-Applicable' and AvailableStrategies[nIndex2].RatingResult.sStatus ~= 'Not-Applicable' and + AvailableStrategies[nIndex1].RatingResult.sStatus == AvailableStrategies[nIndex2].RatingResult.sStatus then + local dCompositeRatingStrategy1 = AvailableStrategies[nIndex1].RatingResult.dRating + AvailableStrategies[nIndex1].RatingResult.dCompletionIndex + local dCompositeRatingStrategy2 = AvailableStrategies[nIndex2].RatingResult.dRating + AvailableStrategies[nIndex2].RatingResult.dCompletionIndex -- si predilige strategia con rating composito più alto if dCompositeRatingStrategy1 > dCompositeRatingStrategy2 then dChosenIndex = nIndex1 @@ -701,7 +701,7 @@ local function GetBestStrategy( vProcSingleRot, Part) for i = 1, #vProcSingleRot do -- processo tutte le feature attive local Proc = vProcSingleRot[i] - if Proc.Flg ~= 0 then + if Proc.nFlg ~= 0 then -- controllo se ci sono strategie disponibili if Proc.AvailableStrategies and #Proc.AvailableStrategies > 0 then local nIndexBestStrategy = 0 @@ -709,7 +709,7 @@ local function GetBestStrategy( vProcSingleRot, Part) for nIndexCurrentStrategy = 1, #Proc.AvailableStrategies do -- eseguo file config con i parametri di default local CurrentStrategy = {} - CurrentStrategy = RunStrategyLibraries( Proc.AvailableStrategies[nIndexCurrentStrategy].StrategyId) + CurrentStrategy = RunStrategyLibraries( Proc.AvailableStrategies[nIndexCurrentStrategy].sStrategyId) -- controllo che le librerie siano state effettivamente caricate if CurrentStrategy.Config and CurrentStrategy.Script then -- eseguo la strategia solo come calcolo fattibilità e voto. Non si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati @@ -721,7 +721,7 @@ local function GetBestStrategy( vProcSingleRot, Part) -- se scelta strategia standard, esco subito alla prima che trovo completa -- TODO serve paraemtro da Beam&Wall ( oppure da confirgurazione) !!!!!!!! if BEAM.GetFirstCompletedStrategy and nIndexBestStrategy > 0 then - if Proc.AvailableStrategies[nIndexBestStrategy].RatingResult.Status == 'Complete' then + if Proc.AvailableStrategies[nIndexBestStrategy].RatingResult.sStatus == 'Complete' then break end end @@ -729,7 +729,7 @@ local function GetBestStrategy( vProcSingleRot, Part) -- se non trovo i file della strategia, scrivo che non è più disponibile else Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult = {} - Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult.Info = 'Strategy not found' + Proc.AvailableStrategies[nIndexCurrentStrategy].RatingResult.sInfo = 'Strategy not found' end end -- salvo sulla proc la migliore strategia @@ -749,9 +749,9 @@ local function ExecPieceFeatures( vProc, Part) for i = 1, #vProc do -- processo tutte le feature attive applicando le lavorazioni local Proc = vProc[i] - if Proc.Flg ~= 0 and Proc.ChosenStrategy then + if Proc.nFlg ~= 0 and Proc.ChosenStrategy then -- carico file script strategia (non serve verificare presenza del file perchè già fatto durante scelta strategia) - local StrategyScriptName = Proc.ChosenStrategy.StrategyId .. '\\' .. Proc.ChosenStrategy.StrategyId + local StrategyScriptName = Proc.ChosenStrategy.sStrategyId .. '\\' .. Proc.ChosenStrategy.sStrategyId local StrategyScript = require( StrategyScriptName) -- eseguo la strategia e si applicano le lavorazioni. Si passa la Proc e i parametri personalizzati Proc = StrategyScript.Make( true, Proc, Part, Proc.ChosenStrategy.Parameters) @@ -766,13 +766,13 @@ local function PrintFeatures( vProc, Part) for i = 1, #vProc do local Proc = vProc[i] local sOut = string.format( ' Id=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Down=%s Side=%s Head=%s Tail=%s Fcse=%1d,%1d Diam=%.2f Fct=%2d Box=%s TopoName=%s', - Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId, - Proc.Flg, EgtIf( Proc.Down, 'T', 'F'), EgtIf( Proc.Side, 'T', 'F'), - EgtIf( Proc.Head, 'T', 'F'), EgtIf( Proc.Tail, 'T', EgtIf( Proc.AdvTail, 'A', 'F')), - Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, tostring( Proc.Box), Proc.Topology.Name or '') + Proc.Id, Proc.nGrp, Proc.nPrc, Proc.idTask, Proc.idCut, + Proc.nFlg, EgtIf( Proc.bDown, 'T', 'F'), EgtIf( Proc.bSide, 'T', 'F'), + EgtIf( Proc.bHead, 'T', 'F'), EgtIf( Proc.bTail, 'T', EgtIf( Proc.bAdvTail, 'A', 'F')), + Proc.nFcs, Proc.nFce, Proc.dDiam, Proc.nFct, tostring( Proc.b3Box), Proc.Topology.sName or '') -- info speciali per Block Haus Half Lap - if Proc.Prc == 37 then - local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.HeadDir, 'T', 'F')) + if Proc.nPrc == 37 then + local sSpec = string.format( ' N=%s Hd=%s', tostring( Proc.vtN or V_NULL()), EgtIf( Proc.bHeadDir, 'T', 'F')) sOut = sOut .. sSpec end EgtOutLog( sOut) @@ -786,12 +786,12 @@ function BeamExec.ProcessFeatures() local Stats = {} local nOrd = 1 local Part = {} - Part.IdRaw = EgtGetFirstRawPart() - while Part.IdRaw do + Part.idRaw = EgtGetFirstRawPart() + while Part.idRaw do -- verifico che il grezzo contenga pezzi oppure sia abbastanza lungo da essere scaricato coi carrelli - local nPartId = EgtGetFirstPartInRawPart( Part.IdRaw) - Part.RawBox = EgtGetRawPartBBox( Part.IdRaw) - if not nPartId and Part.RawBox:getDimX() < BeamData.MinRaw then break end + local nPartId = EgtGetFirstPartInRawPart( Part.idRaw) + Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw) + if not nPartId and Part.b3RawBox:getDimX() < BeamData.dMinRaw then break end -- per ogni rotazione, calcolo come lavorare le feature per decidere posizionamento iniziale e in che rotazione verranno lavorate le singole feature local vProcRot = {} @@ -816,19 +816,19 @@ function BeamExec.ProcessFeatures() -- ruoto il grezzo per calcolare la fattibilità delle lavorazioni nella prossima rotazione -- vettore movimento grezzi per rotazione di 90deg ogni step - local dDeltaYZ = Part.RawBox:getDimY() - Part.RawBox:getDimZ() + local dDeltaYZ = Part.b3RawBox:getDimY() - Part.b3RawBox:getDimZ() local vtMove = Vector3d( 0, dDeltaYZ / 2 * EgtIf( BeamData.RIGHT_LOAD, -1, 1), dDeltaYZ / 2) local bPreMove = ( dDeltaYZ < 0) -- ruoto le travi della fase corrente if bPreMove then - EgtMoveRawPart( Part.IdRaw, vtMove) + EgtMoveRawPart( Part.idRaw, vtMove) end - EgtRotateRawPart( Part.IdRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) + EgtRotateRawPart( Part.idRaw, X_AX(), EgtIf( BeamData.RIGHT_LOAD, -90, 90)) if not bPreMove then - EgtMoveRawPart( Part.IdRaw, vtMove) + EgtMoveRawPart( Part.idRaw, vtMove) end -- aggiorno info pezzo - Part.RawBox = EgtGetRawPartBBox( Part.IdRaw) + Part.b3RawBox = EgtGetRawPartBBox( Part.idRaw) end -- TODO da rimuovere o lasciare solo per debug @@ -844,13 +844,13 @@ function BeamExec.ProcessFeatures() if nOrd == 1 then EgtSetCurrPhase( 1) else - BeamLib.AddPhaseWithRawParts( Part, BeamData.OriXR, BeamData.PosXR, 0) + BeamLib.AddPhaseWithRawParts( Part, BeamData.ptOriXR, BeamData.dPosXR, 0) end local nPhase = EgtGetCurrPhase() local nDispId = EgtGetPhaseDisposition( nPhase) EgtSetInfo( nDispId, 'TYPE', EgtIf( nPartId, 'START', 'REST')) EgtSetInfo( nDispId, 'ORD', nOrd) - EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( Part.IdRaw) .. ' Part=' .. tostring( nPartId) .. ' ***', 1) + EgtOutLog( ' *** Phase=' .. tostring( nPhase) .. ' Raw=' .. tostring( Part.idRaw) .. ' Part=' .. tostring( nPartId) .. ' ***', 1) -- debug if EgtGetDebugLevel() >= 1 then @@ -878,7 +878,7 @@ function BeamExec.ProcessFeatures() EgtOutLog( ' *** End AddMachinings ***', 1) -- passo al grezzo successivo nOrd = nOrd + 1 - Part.IdRaw = EgtGetNextRawPart( Part.IdRaw) + Part.idRaw = EgtGetNextRawPart( Part.idRaw) end return ( nTotErr == 0), Stats diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index b4075bd..22889b5 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -92,7 +92,7 @@ end ------------------------------------------------------------------------------------------------------------- function BeamLib.AddPhaseWithRawParts( Part, OriXR, PosXR, dDeltaSucc) EgtAddPhase() - local nRawId = Part.IdRaw + local nRawId = Part.idRaw local dRawMove = 0 while nRawId do EgtKeepRawPart( nRawId) @@ -148,27 +148,27 @@ end ------------------------------------------------------------------------------------------------------------- -- restituisce le facce della parte interessate dalla feature Proc function BeamLib.GetAffectedFaces( Proc) - local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') + local nBoxSolidId = EgtGetFirstNameInGroup( Proc.idPart or GDB_ID.NULL, 'Box') local b3Part = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) - local vtFacesAffected = { Top = false, Bottom = false, Front = false, Back = false, Left = false, Right = false} - if Proc.Box and not Proc.Box:isEmpty() then - if Proc.Box:getMax():getZ() > b3Part:getMax():getZ() - 500 * GEO.EPS_SMALL then - vtFacesAffected.Top = true + local vtFacesAffected = { bTop = false, bBottom = false, bFront = false, bBack = false, bLeft = false, bRight = false} + if Proc.b3Box and not Proc.b3Box:isEmpty() then + if Proc.b3Box:getMax():getZ() > b3Part:getMax():getZ() - 500 * GEO.EPS_SMALL then + vtFacesAffected.bTop = true end - if Proc.Box:getMin():getZ() < b3Part:getMin():getZ() + 500 * GEO.EPS_SMALL then - vtFacesAffected.Bottom = true + if Proc.b3Box:getMin():getZ() < b3Part:getMin():getZ() + 500 * GEO.EPS_SMALL then + vtFacesAffected.bBottom = true end - if Proc.Box:getMin():getY() < b3Part:getMin():getY() + 500 * GEO.EPS_SMALL then - vtFacesAffected.Front = true + if Proc.b3Box:getMin():getY() < b3Part:getMin():getY() + 500 * GEO.EPS_SMALL then + vtFacesAffected.bFront = true end - if Proc.Box:getMax():getY() > b3Part:getMax():getY() - 500 * GEO.EPS_SMALL then - vtFacesAffected.Back = true + if Proc.b3Box:getMax():getY() > b3Part:getMax():getY() - 500 * GEO.EPS_SMALL then + vtFacesAffected.bBack = true end - if Proc.Box:getMin():getX() < b3Part:getMin():getX() + 500 * GEO.EPS_SMALL then - vtFacesAffected.Left = true + if Proc.b3Box:getMin():getX() < b3Part:getMin():getX() + 500 * GEO.EPS_SMALL then + vtFacesAffected.bLeft = true end - if Proc.Box:getMax():getX() > b3Part:getMax():getX() - 500 * GEO.EPS_SMALL then - vtFacesAffected.Right = true + if Proc.b3Box:getMax():getX() > b3Part:getMax():getX() - 500 * GEO.EPS_SMALL then + vtFacesAffected.bRight = true end end @@ -178,7 +178,7 @@ 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) - nAddGrpId = nAddGrpId or BeamLib.GetAddGroup( Proc.PartId) + nAddGrpId = nAddGrpId or BeamLib.GetAddGroup( Proc.idPart) if not nAddGrpId then local nEdges = #(EgtSurfTmFacetAdjacencies( Proc.Id, idFace)[1]) return ( nEdges == 3) @@ -227,14 +227,14 @@ function BeamLib.GetFaceHvRefDim( nSurfId, idFace, Part) local dDimH = b3HV:getDimX() local dDimV = b3HV:getDimY() -- se definito grezzo (o solido), applico eventuali limiti - if Part.RawBox then + if Part.b3RawBox then local dCoeffY = abs( frHV:getVersX():getY()) if dCoeffY > GEO.EPS_SMALL then - dDimH = min( dDimH, Part.RawBox:getDimY() / dCoeffY) + dDimH = min( dDimH, Part.b3RawBox:getDimY() / dCoeffY) end local dCoeffZ = abs( frHV:getVersY():getZ()) if dCoeffZ > GEO.EPS_SMALL then - dDimV = min( dDimV, Part.RawBox:getDimZ() / dCoeffZ) + dDimV = min( dDimV, Part.b3RawBox:getDimZ() / dCoeffZ) end end @@ -250,8 +250,8 @@ function BeamLib.GetUpdateCustomParameters( CustomStrategyParamList, DefaultStra if CustomStrategyParamList and #CustomStrategyParamList > 0 then for i = 1, #DefaultStrategyParamList do for j = 1, #CustomStrategyParamList do - if DefaultStrategyParamList[i].Name == CustomStrategyParamList[j].Name then - DefaultStrategyParamList[i].Value = CustomStrategyParamList[j].Value + if DefaultStrategyParamList[i].sName == CustomStrategyParamList[j].sName then + DefaultStrategyParamList[i].sValue = CustomStrategyParamList[j].sValue end end end @@ -265,12 +265,12 @@ function BeamLib.LoadCustomParametersInStrategy( CustomParameters) local Parameters = {} if CustomParameters and #CustomParameters > 0 then for i=1, #CustomParameters do - if CustomParameters[i].Type == 'b' then - Parameters[CustomParameters[i].Name] = CustomParameters[i].Value == 'true' + if CustomParameters[i].sType == 'b' then + Parameters[CustomParameters[i].sName] = CustomParameters[i].sValue == 'true' elseif CustomParameters[i].Type == 'd' then - Parameters[CustomParameters[i].Name] = tonumber( CustomParameters[i].Value) + Parameters[CustomParameters[i].sName] = tonumber( CustomParameters[i].sValue) else -- CustomParameters.Type == 's' - Parameters[CustomParameters[i].Name] = CustomParameters[i].Value + Parameters[CustomParameters[i].sName] = CustomParameters[i].sValue end end end diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index 1251de5..25366b3 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -15,9 +15,9 @@ function FaceData.GetAdjacencyMatrix( Proc) local vAdj = {} -- essendo la matrice simmetrica a diagonale nulla, ne calcolo solo la metà superiore - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do vAdj[i] = {} - for j = i + 1, Proc.Fct do + for j = i + 1, Proc.nFct do _, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT) if not vAdj[i][j] then vAdj[i][j] = 0 @@ -26,9 +26,9 @@ function FaceData.GetAdjacencyMatrix( Proc) end -- riempio di conseguenza il resto della matrice - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do vAdj[i][i] = 0 - for j = i + 1, Proc.Fct do + for j = i + 1, Proc.nFct do vAdj[j][i] = vAdj[i][j] end @@ -40,13 +40,13 @@ end -- restituisce un vettore con gli indici (0 based) delle facce triangolari (o quasi) di Proc function FaceData.GetTriangularFaces( Proc) -- se la feature ha una sola faccia, esco subito - if Proc.Fct <= 1 then + if Proc.nFct <= 1 then return end local vTriangularFaces = {} - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do if BeamLib.Is3EdgesApprox( Proc, i - 1) then table.insert( vTriangularFaces, i - 1) end @@ -59,7 +59,7 @@ end local function GetNotAdjacentFaces( Proc, idFace) local NotAdjacentFaces = {} - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do if Proc.Faces[i].Id ~= idFace then local bIsAdjacent = false for j = 1, #Proc.Faces[idFace + 1].Adjacencies do @@ -94,7 +94,7 @@ end -- restituisce una tabella che correla numero di adiacenze e id delle facce con quello stesso numero di adiacenze function FaceData.GetFacesByAdjacencyNumber( Proc) -- se la feature ha una sola faccia, esco subito - if Proc.Fct <= 1 then + if Proc.nFct <= 1 then return end @@ -103,7 +103,7 @@ function FaceData.GetFacesByAdjacencyNumber( Proc) for i = 1, 10 do FacesByAdjacencyNumber[i] = {} end - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do table.insert( FacesByAdjacencyNumber[#Proc.Faces[i].Adjacencies], Proc.Faces[i]) end @@ -115,7 +115,7 @@ function FaceData.GetFacesInfo( Proc, Part) EgtOutLog( '---Faces START---') local Faces = {} - local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.PartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + local b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.idPart, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) local vAdj if Proc.AdjacencyMatrix then vAdj = Proc.AdjacencyMatrix @@ -123,32 +123,32 @@ function FaceData.GetFacesInfo( Proc, Part) vAdj = FaceData.GetAdjacencyMatrix( Proc) end - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do -- reset colore faccia EgtSurfTmSetFaceColor( Proc.Id, i - 1, 0) Faces[i] = {} Faces[i].Id = i - 1 - Faces[i].PtCenter, Faces[i].VtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) - if Proc.Fct < 6 then + Faces[i].ptCenter, Faces[i].vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT) + if Proc.nFct < 6 then local frHV, dFaceWidth, dFaceHeight = BeamLib.GetFaceHvRefDim( Proc.Id, i - 1, Part) -- frame OCS faccia - Faces[i].FrameHV = frHV + Faces[i].vtFrameHV = frHV -- larghezza OCS faccia - Faces[i].Width = dFaceWidth + Faces[i].dWidth = dFaceWidth -- altezza OCS faccia - Faces[i].Height = dFaceHeight + Faces[i].dHeight = dFaceHeight -- elevazione calcolata rispetto al box della parte - Faces[i].Elevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, true, GDB_ID.ROOT) + Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, true, GDB_ID.ROOT) -- TODO valutare se fare un output unico alla fine o gestire log in altro modo - EgtOutLog( 'Facet ' .. Faces[i].Id .. ' of ' .. Proc.Fct - 1) - EgtOutLog( ' VtN: ' .. tostring( Faces[i].VtN)) + EgtOutLog( 'Facet ' .. Faces[i].Id .. ' of ' .. Proc.nFct - 1) + EgtOutLog( ' vtN: ' .. tostring( Faces[i].vtN)) -- adiacenze della faccia -- TODO chiamarle in modo che si capisca che sono solo gli id e non l'intero oggetto faccia Faces[i].Adjacencies = {} - for j = 1, Proc.Fct do + for j = 1, Proc.nFct do if vAdj[i][j] and vAdj[i][j] ~= 0 and ( i ~= j) then table.insert( Faces[i].Adjacencies, j - 1) if EgtGetDebugLevel() >= 3 then @@ -170,23 +170,23 @@ local function GetTunnelFaces( Proc) local TunnelAddedFaces = {} -- TODO scrivere il box della parte nella Proc o fare funzione per recuperarlo - local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.PartId, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) + local b3Part = EgtGetBBoxGlob( EgtGetFirstNameInGroup( Proc.idPart, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) - if not ( Proc.Topology.IsThrough and Proc.Topology.AllRightAngles and Proc.Fct < 5) then + if not ( Proc.Topology.bIsThrough and Proc.Topology.bAllRightAngles and Proc.nFct < 5) then error( 'GetTunnelFaces : Topology not implemented') end -- direzione del tunnel - local vtTunnelDirection = Proc.Faces[1].VtN ^ Proc.Faces[ Proc.Faces[1].Adjacencies[1] + 1].VtN + local vtTunnelDirection = Proc.Faces[1].vtN ^ Proc.Faces[ Proc.Faces[1].Adjacencies[1] + 1].vtN -- centro del tunnel - local frTunnel = Frame3d( Proc.Faces[1].PtCenter, vtTunnelDirection) + local frTunnel = Frame3d( Proc.Faces[1].ptCenter, vtTunnelDirection) local b3Tunnel = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTunnel) local ptTunnelCenter = b3Tunnel:getCenter() ptTunnelCenter:toGlob( frTunnel) -- recupero gruppo per geometria addizionale - local nAddGrpId = BeamLib.GetAddGroup( Proc.PartId) + local nAddGrpId = BeamLib.GetAddGroup( Proc.idPart) if not nAddGrpId then -- TODO gestire meglio questo errore. Non conviene creare e verificare all'inizio se il gruppo esiste? EgtOutLog( 'Error : missing AddGroup') @@ -197,8 +197,8 @@ local function GetTunnelFaces( Proc) TunnelAddedFaces.MiddleFaceTm = {} TunnelAddedFaces.MiddleFaceTm.Id = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, b3Part, GDB_ID.ROOT) -- TODO se non si riesce a costruire la faccia bisogna dare errore o semplicemente non ritornarla?? - for i = 1, Proc.Fct do - EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.Id, Proc.Faces[i].PtCenter, -Proc.Faces[i].VtN, false, GDB_ID.ROOT) + for i = 1, Proc.nFct do + EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.Id, Proc.Faces[i].ptCenter, -Proc.Faces[i].vtN, false, GDB_ID.ROOT) end return TunnelAddedFaces @@ -208,21 +208,21 @@ end local function GetBottomFace( Proc) local BottomFace = {} - if Proc.Topology.Family == 'Tunnel' then + if Proc.Topology.sFamily == 'Tunnel' then return nil - elseif not ( Proc.Topology.Family == 'Rabbet' or Proc.Topology.Family == 'VGroove' or Proc.Topology.Family == 'Groove' or Proc.Topology.Family == 'Pocket') then + elseif not ( Proc.Topology.sFamily == 'Rabbet' or Proc.Topology.sFamily == 'VGroove' or Proc.Topology.sFamily == 'Groove' or Proc.Topology.sFamily == 'Pocket') then error( 'GetBottomFace : Topology not implemented') end -- la faccia di fondo ha sempre Fct - 1 adiacenze. Se si trovano più facce di fondo si sceglie quella con minor elevazione local FacesByAdjacencyNumber = FaceData.GetFacesByAdjacencyNumber( Proc) if FacesByAdjacencyNumber then - local BottomFaces = FacesByAdjacencyNumber[ Proc.Fct - 1] + local BottomFaces = FacesByAdjacencyNumber[ Proc.nFct - 1] if #BottomFaces > 1 then local dMinElevation = GEO.INFINITO for i = 1, #BottomFaces do - if Proc.Faces[BottomFaces[i].Id + 1].Elevation < dMinElevation then - dMinElevation = Proc.Faces[BottomFaces[i].Id + 1].Elevation + if Proc.Faces[BottomFaces[i].Id + 1].dElevation < dMinElevation then + dMinElevation = Proc.Faces[BottomFaces[i].Id + 1].dElevation BottomFace = Proc.Faces[BottomFaces[i].Id + 1] end end @@ -237,13 +237,13 @@ end local function GetLongFaces( Proc, MainFaces) local LongFaces = {} - if Proc.Fct > 5 then + if Proc.nFct > 5 then error( 'GetLongFaces : Topology not implemented') end local idBottomFace = GDB_ID.NULL local idTunnelMiddleFace = GDB_ID.NULL - if Proc.Topology.Family == 'Tunnel' then + if Proc.Topology.sFamily == 'Tunnel' then if MainFaces.TunnelAddedFaces then idTunnelMiddleFace = MainFaces.TunnelAddedFaces.MiddleFaceTm.Id else @@ -260,10 +260,10 @@ local function GetLongFaces( Proc, MainFaces) end local FacesToAnalyze = {} - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do if Proc.Faces[i].Id ~= idBottomFace then table.insert( FacesToAnalyze, Proc.Faces[i]) - if Proc.Topology.Family == 'Tunnel' then + if Proc.Topology.sFamily == 'Tunnel' then -- TODO questo non funziona nei tunnel, da modificare FacesToAnalyze[#FacesToAnalyze].LengthOnMainFace = GetFacesContactLength( Proc, idTunnelMiddleFace, Proc.Faces[i].Id) else @@ -276,7 +276,7 @@ local function GetLongFaces( Proc, MainFaces) -- la prima faccia lunga è sempre la prima della lista LongFaces[1] = FacesToAnalyze[1] -- si cerca l'eventuale seconda faccia lunga, ossia quella non adiacente alla prima - if Proc.Fct > 3 then + if Proc.nFct > 3 then local NotAdjacentFaces = GetNotAdjacentFaces(Proc, LongFaces[1].Id) if #NotAdjacentFaces > 0 then LongFaces[2] = NotAdjacentFaces[1] @@ -290,12 +290,12 @@ end local function GetSideFaces( Proc, MainFaces) local SideFaces = {} - if Proc.Fct > 5 then + if Proc.nFct > 5 then error( 'GetSideFaces : Topology not implemented') end local idBottomFace = GDB_ID.NULL - if Proc.Topology.Family ~= 'Tunnel' then + if Proc.Topology.sFamily ~= 'Tunnel' then if MainFaces.BottomFace then idBottomFace = MainFaces.BottomFace.Id else @@ -312,7 +312,7 @@ local function GetSideFaces( Proc, MainFaces) end - for i = 1, Proc.Fct do + for i = 1, Proc.nFct do if not idBottomFace or i ~= ( idBottomFace + 1) then local bIsSideFace = true for j = 1, #LongFaces do @@ -338,9 +338,9 @@ function FaceData.GetMainFaces( Proc) local MainFaces = {} -- CASO 1 : Feature tipo LapJoint - if Proc.Topology.Family == 'Rabbet' or Proc.Topology.Family == 'VGroove' or Proc.Topology.Family == 'Groove' or Proc.Topology.Family == 'Pocket' or Proc.Topology.Family == 'Tunnel' then + if Proc.Topology.sFamily == 'Rabbet' or Proc.Topology.sFamily == 'VGroove' or Proc.Topology.sFamily == 'Groove' or Proc.Topology.sFamily == 'Pocket' or Proc.Topology.sFamily == 'Tunnel' then - if Proc.Topology.IsThrough and Proc.Topology.AllRightAngles and Proc.Fct < 5 then + if Proc.Topology.bIsThrough and Proc.Topology.bAllRightAngles and Proc.nFct < 5 then MainFaces.TunnelAddedFaces = GetTunnelFaces( Proc) end diff --git a/LuaLibs/FeatureData.lua b/LuaLibs/FeatureData.lua index 59dff4b..993eaf2 100644 --- a/LuaLibs/FeatureData.lua +++ b/LuaLibs/FeatureData.lua @@ -48,11 +48,11 @@ function FeatureData.NeedTopologyFeature( Proc) return true -- calcolo topologia SOLO se non raggiata -- TODO oppure riconoscerla come feature speciale; valutare se controllare il numero di facce è un metodo efficace - elseif ID.IsMortise( Proc) and Proc.Fct < 6 then + elseif ID.IsMortise( Proc) and Proc.nFct < 6 then return true -- calcolo topologia SOLO se non raggiata -- TODO oppure riconoscerla come feature speciale; valutare se controllare il numero di facce è un metodo efficace - elseif ID.IsFrontMortise( Proc) and Proc.Fct < 6 then + elseif ID.IsFrontMortise( Proc) and Proc.nFct < 6 then return true end @@ -96,12 +96,12 @@ end -- restituisce true se almeno una delle dimensioni della feature è maggiore o uguale ad una delle dimensioni principali del pezzo (tolleranza 1 mm) local function IsAnyDimensionLongAsPart( Proc) local bResult = false - local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box') + local nBoxSolidId = EgtGetFirstNameInGroup( Proc.idPart or GDB_ID.NULL, 'Box') local b3Solid = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) - if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or - Proc.Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or - Proc.Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then + if Proc.b3Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or + Proc.b3Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or + Proc.b3Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then bResult = true end @@ -111,14 +111,14 @@ end ------------------------------------------------------------------------------------------------------------- -- restituisce vero se la feature con box b3Proc taglia l'intera sezione della barra, rappresentata dalle sue dimensioni W e H local function IsFeatureCuttingEntireSection( b3Proc, Part) - return ( b3Proc:getDimY() > ( Part.RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimZ() > ( Part.RawBox:getDimZ() - 500 * GEO.EPS_SMALL)) + return ( b3Proc:getDimY() > ( Part.b3RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimZ() > ( Part.b3RawBox:getDimZ() - 500 * GEO.EPS_SMALL)) end ------------------------------------------------------------------------------------------------------------- -- restituisce vero se la feature con box b3Proc taglia l'intera lunghezza della barra, rappresentata dalle sue dimensioni W e L oppure H e L local function IsFeatureCuttingEntireLength( b3Proc, Part) - return ( ( b3Proc:getDimY() > ( Part.RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.RawBox:getDimX() - 500 * GEO.EPS_SMALL)) or - ( b3Proc:getDimZ() > ( Part.RawBox:getDimZ() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.RawBox:getDimX() - 500 * GEO.EPS_SMALL))) + return ( ( b3Proc:getDimY() > ( Part.b3RawBox:getDimY() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3RawBox:getDimX() - 500 * GEO.EPS_SMALL)) or + ( b3Proc:getDimZ() > ( Part.b3RawBox:getDimZ() - 500 * GEO.EPS_SMALL) and b3Proc:getDimX() > ( Part.b3RawBox:getDimX() - 500 * GEO.EPS_SMALL))) end --------------------------------------------------------------------- @@ -135,8 +135,8 @@ function FeatureData.ClassifyTopology( Proc, Part) if not Proc.AffectedFaces then Proc.AffectedFaces = BeamLib.GetAffectedFaces( Proc) end - local bIsFeatureCuttingEntireSection = IsFeatureCuttingEntireSection( Proc.Box, Part) - local bIsFeatureCuttingEntireLength = IsFeatureCuttingEntireLength( Proc.Box, Part) + local bIsFeatureCuttingEntireSection = IsFeatureCuttingEntireSection( Proc.b3Box, Part) + local bIsFeatureCuttingEntireLength = IsFeatureCuttingEntireLength( Proc.b3Box, Part) local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) local vAdj = Proc.AdjacencyMatrix local bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( vAdj) @@ -145,63 +145,63 @@ function FeatureData.ClassifyTopology( Proc, Part) local sFamily local bIsThrough - if Proc.Fct == 1 and ( bIsFeatureCuttingEntireSection or bIsFeatureCuttingEntireLength) then + if Proc.nFct == 1 and ( bIsFeatureCuttingEntireSection or bIsFeatureCuttingEntireLength) then sFamily = 'Cut' bIsThrough = true - elseif Proc.Fct == 1 then + elseif Proc.nFct == 1 then sFamily = 'Bevel' bIsThrough = true - elseif Proc.Fct == 2 and bAllAnglesConcave and #vTriangularFaces == 1 then + elseif Proc.nFct == 2 and bAllAnglesConcave and #vTriangularFaces == 1 then sFamily = 'Bevel' bIsThrough = false - elseif Proc.Fct == 2 and bAllAnglesConcave and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right) and ( Proc.AffectedFaces.Front or Proc.AffectedFaces.Back) then + elseif Proc.nFct == 2 and bAllAnglesConcave and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right) and ( Proc.AffectedFaces.Front or Proc.AffectedFaces.Back) then sFamily = 'Rabbet' bIsThrough = true - elseif Proc.Fct == 2 and bAllAnglesConcave then + elseif Proc.nFct == 2 and bAllAnglesConcave then sFamily = 'VGroove' bIsThrough = true - elseif Proc.Fct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then + elseif Proc.nFct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then sFamily = 'DoubleBevel' bIsThrough = true - elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and #vTriangularFaces == 2 then + elseif Proc.nFct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and #vTriangularFaces == 2 then sFamily = 'Bevel' bIsThrough = false - elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and bIsAnyDimensionLongAsPart then + elseif Proc.nFct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and bIsAnyDimensionLongAsPart then sFamily = 'Groove' bIsThrough = true - elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 3 then + elseif Proc.nFct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 3 then sFamily = 'Groove' bIsThrough = false - elseif Proc.Fct == 4 and #vFacesByAdjNumber[2] == 4 and #vTriangularFaces == 2 then + elseif Proc.nFct == 4 and #vFacesByAdjNumber[2] == 4 and #vTriangularFaces == 2 then sFamily = 'DoubleBevel' bIsThrough = false - elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[3] == 2 then + elseif Proc.nFct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[3] == 2 then sFamily = 'Groove' bIsThrough = false - elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 4 and bIsAnyDimensionLongAsPart then + elseif Proc.nFct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 4 and bIsAnyDimensionLongAsPart then sFamily = 'Tunnel' bIsThrough = true - elseif Proc.Fct >= 4 and #vFacesByAdjNumber[1] == 2 and bIsAnyDimensionLongAsPart then + elseif Proc.nFct >= 4 and #vFacesByAdjNumber[1] == 2 and bIsAnyDimensionLongAsPart then sFamily = 'Strip' bIsThrough = true - elseif Proc.Fct == 5 and bAllAnglesConcave and #vFacesByAdjNumber[4] == 1 then + elseif Proc.nFct == 5 and bAllAnglesConcave and #vFacesByAdjNumber[4] == 1 then sFamily = 'Pocket' bIsThrough = false - elseif Proc.Fct == 6 and #vFacesByAdjNumber[2] == 4 and #vFacesByAdjNumber[3] == 2 and #vTriangularFaces == 4 then + elseif Proc.nFct == 6 and #vFacesByAdjNumber[2] == 4 and #vFacesByAdjNumber[3] == 2 and #vTriangularFaces == 4 then sFamily = 'DoubleBevel' bIsThrough = false end if sFamily then - FeatureTopology.Family = sFamily - FeatureTopology.IsThrough = bIsThrough - FeatureTopology.AllRightAngles = bAllRightAngles - FeatureTopology.Name = GetTopologyName( sFamily, Proc.Fct, bIsThrough) + FeatureTopology.sFamily = sFamily + FeatureTopology.bIsThrough = bIsThrough + FeatureTopology.bAllRightAngles = bAllRightAngles + FeatureTopology.sName = GetTopologyName( sFamily, Proc.nFct, bIsThrough) FeatureTopology.AdjacencyMatrix = vAdj -- feature che necessita di essere catalogata, ma non si capisce come else - FeatureTopology.Family = 'NOT_IMPLEMENTED' - FeatureTopology.Name = FeatureTopology.Family + FeatureTopology.sFamily = 'NOT_IMPLEMENTED' + FeatureTopology.sName = FeatureTopology.sFamily end return FeatureTopology diff --git a/LuaLibs/Identity.lua b/LuaLibs/Identity.lua index 8b1078d..e54fb91 100644 --- a/LuaLibs/Identity.lua +++ b/LuaLibs/Identity.lua @@ -10,12 +10,12 @@ local Identity = {} --------------------------------------------------------------------- -- Feature : Head Cut function Identity.IsHeadCut( Proc) - return ( Proc.Grp == 1 and Proc.Prc == 340) + return ( Proc.nGrp == 1 and Proc.nPrc == 340) end --------------------------------------------------------------------- -- Feature : Split Cut function Identity.IsSplitCut( Proc) - return ( Proc.Grp == 2 and Proc.Prc == 350) + return ( Proc.nGrp == 2 and Proc.nPrc == 350) end --------------------------------------------------------------------- @@ -23,252 +23,252 @@ end --------------------------------------------------------------------- -- Feature : Cut function Identity.IsCut( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 10) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 10) end --------------------------------------------------------------------- -- Feature : Longitudinal Cut function Identity.IsLongitudinalCut( Proc) - return (( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 10) + return (( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 10) end --------------------------------------------------------------------- -- Feature : Double Cut function Identity.IsDoubleCut( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 11) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 11) end --------------------------------------------------------------------- -- Feature : Ridge or Valley Cut function Identity.IsDoubleLongitudinalCut( Proc) - return ( Proc.Grp == 0 and Proc.Prc == 12) + return ( Proc.nGrp == 0 and Proc.nPrc == 12) end --------------------------------------------------------------------- -- Feature : Saw Cut function Identity.IsSawCut( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 13) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 13) end --------------------------------------------------------------------- -- Feature : Slot function Identity.IsSlot( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 16) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 16) end --------------------------------------------------------------------- -- Feature : Front Slot function Identity.IsFrontSlot( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 17) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 17) end --------------------------------------------------------------------- -- Feature : Birds Mouth function Identity.IsBirdsMouth( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 20) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 20) end --------------------------------------------------------------------- -- Feature : Hip or Valley Rafter Notch function Identity.IsHipValleyRafterNotch( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 25) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 25) end --------------------------------------------------------------------- -- Feature : Ridge Lap function Identity.IsRidgeLap( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 30) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 30) end --------------------------------------------------------------------- -- Feature : Lap Joint function Identity.IsLapJoint( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 30) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 30) end --------------------------------------------------------------------- -- Feature : Notch/Rabbet function Identity.IsNotchRabbet( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 32) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 32) end --------------------------------------------------------------------- -- Feature : Block Haus function Identity.IsBlockHaus( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 33) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 33) end --------------------------------------------------------------------- -- Feature : Notch function Identity.IsNotch( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 34) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 34) end --------------------------------------------------------------------- -- Feature : French Ridge Lap function Identity.IsFrenchRidgeLap( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 35) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 35) end --------------------------------------------------------------------- -- Feature : Chamfer function Identity.IsChamfer( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 36) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 36) end --------------------------------------------------------------------- -- Feature : Block Haus Half Lap function Identity.IsHalfBlockHaus( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 37) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 37) end --------------------------------------------------------------------- -- Feature : Block Haus Front function Identity.IsFrontBlockHaus( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 38) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 38) end --------------------------------------------------------------------- -- Feature : Pocket function Identity.IsPocket( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 39) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 39) end --------------------------------------------------------------------- -- Feature : Drilling function Identity.IsDrilling( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 40) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 40) end --------------------------------------------------------------------- -- Feature : Tenon function Identity.IsTenon( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 50) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 50) end --------------------------------------------------------------------- -- Feature : Mortise function Identity.IsMortise( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 50) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 50) end --------------------------------------------------------------------- -- Feature : Front Mortise function Identity.IsFrontMortise( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 51) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 51) end --------------------------------------------------------------------- -- Feature : House function Identity.IsHouse( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 52) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 52) end --------------------------------------------------------------------- -- Feature : House Mortise function Identity.IsHouseMortise( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 53) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 53) end --------------------------------------------------------------------- -- Feature : Dovetail Tenon function Identity.IsDovetailTenon( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 55) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 55) end --------------------------------------------------------------------- -- Feature : Dovetail Mortise function Identity.IsDovetailMortise( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 55) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 55) end --------------------------------------------------------------------- -- Feature : Dovetail Mortise Front function Identity.IsFrontDovetailMortise( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 56) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 56) end --------------------------------------------------------------------- -- Feature : Marking function Identity.IsMarking( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 60) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 60) end --------------------------------------------------------------------- -- Feature : Text function Identity.IsText( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 61) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 61) end --------------------------------------------------------------------- -- Feature : Scarf Simple function Identity.IsScarfSimple( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 70) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 70) end --------------------------------------------------------------------- -- Feature : Scarf Joint function Identity.IsScarfJoint( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 71) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 71) end --------------------------------------------------------------------- -- Feature : Step Joint function Identity.IsStepJoint( Proc) - return ( ( Proc.Grp == 1 or Proc.Grp == 2) and Proc.Prc == 80) + return ( ( Proc.nGrp == 1 or Proc.nGrp == 2) and Proc.nPrc == 80) end --------------------------------------------------------------------- -- Feature : Step Joint Notch function Identity.IsStepJointNotch( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 80) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 80) end --------------------------------------------------------------------- -- Feature : Planing function Identity.IsPlaning( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 90) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 90) end --------------------------------------------------------------------- -- Feature : Front Profile function Identity.IsFrontProfile( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 100) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 100) end --------------------------------------------------------------------- -- Feature : Head Concave Profile function Identity.IsHeadConcaveProfile( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 101) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 101) end --------------------------------------------------------------------- -- Feature : Head Convex Profile function Identity.IsHeadConvexProfile( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 102) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 102) end --------------------------------------------------------------------- -- Feature : Head Cambered Profile function Identity.IsHeadCamberedProfile( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 103) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 103) end --------------------------------------------------------------------- -- Feature : Round Arch function Identity.IsRoundArch( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 104) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 104) end --------------------------------------------------------------------- -- Feature : Head Profile function Identity.IsHeadProfile( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 106) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 106) end --------------------------------------------------------------------- -- Feature : Sphere function Identity.IsSphere( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 107) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 107) end --------------------------------------------------------------------- -- Feature : Triangle Cut function Identity.IsTriangleCut( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 120) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 120) end --------------------------------------------------------------------- -- Feature : TyroleanDovetail function Identity.IsTyroleanDovetail( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 1 or Proc.Grp == 2 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 136) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 1 or Proc.nGrp == 2 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 136) end --------------------------------------------------------------------- -- Feature : Dovetail function Identity.IsDovetail( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 1 or Proc.Grp == 2 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 138) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 1 or Proc.nGrp == 2 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 138) end --------------------------------------------------------------------- -- Feature : Free Contour function Identity.IsFreeContour( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 250) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 250) end --------------------------------------------------------------------- -- Feature : Outline function Identity.IsOutline( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 251) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 251) end --------------------------------------------------------------------- -- Feature : Aperture function Identity.IsAperture( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 252) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 252) end --------------------------------------------------------------------- -- Feature : Variant function Identity.IsVariant( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 1 or Proc.Grp == 2 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 900) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 1 or Proc.nGrp == 2 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 900) end --------------------------------------------------------------------- -- Feature Decor function Identity.IsDecor( Proc) - return ( ( Proc.Grp == 0 or Proc.Grp == 3 or Proc.Grp == 4) and Proc.Prc == 959) + return ( ( Proc.nGrp == 0 or Proc.nGrp == 3 or Proc.nGrp == 4) and Proc.nPrc == 959) end --------------------------------------------------------------------- diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index 834d08c..fdb9e2e 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -8,11 +8,113 @@ local MachiningLib = {} -- Include require( 'EgtBase') +-- Carico i dati globali +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 +local function GetToolEntryAngle( Proc, vtTool) + local dSinAngle = -10 * GEO.EPS_SMALL + local vtNorm + if Proc.AffectedFaces.bTop then + vtNorm = Z_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.bBottom then + vtNorm = -Z_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.bFront then + vtNorm = -Y_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.bBack then + vtNorm = Y_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.bLeft then + vtNorm = -X_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + if Proc.AffectedFaces.bRight then + vtNorm = X_AX() + dSinAngle = max( dSinAngle, vtTool * vtNorm) + end + + local dCosAngle = sqrt( 1 - sqr( dSinAngle)) + local dAngle = acos( dCosAngle) + + return dAngle + + end + ------------------------------------------------------------------------------------------------------------- -- funzione per cercare utensile tipo FRESA con certe caratteristiche -function MachiningLib.FindMill() +function MachiningLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, vtToolDir) + local ToolInfo = {} + + for nCurrIndex=1, #TOOLS do + -- prima verifico che utensile sia compatibile + local bCompatibleTool = true + if TOOLS[nCurrIndex].sType ~= sMillType then + bCompatibleTool = false + elseif TOOLS[nCurrIndex].dDiameter > dMaxToolDiameter then + bCompatibleTool = false + elseif sMillShape == 'STANDARD' and TOOLS[nCurrIndex].dSideAngle ~= 0 then + bCompatibleTool = false + elseif sMillShape == 'DOVETAIL' and not TOOLS[nCurrIndex].bIsDoveTail then + bCompatibleTool = false + elseif sMillShape == 'TSHAPEMILL' and not TOOLS[nCurrIndex].bIsTMill then + bCompatibleTool = false + end + + -- scelgo il migliore + if bCompatibleTool then + -- 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 dCurrMaxMatReduction = BeamData.COLL_SIC or 5 + + -- 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) + end + -- dCurrMachReduction = negativo -> limitare, positivo -> mm extra disponibili + local dCurrMachReduction = TOOLS[nCurrIndex].dMaxDepth - dElevation - dCurrMaxMatReduction + + -- se non ancora trovato, oppure se completo e il migliore fino ad ora non è completo: corrente è il migliore + if not ToolInfo.idTool or ( ToolInfo.dMaxMatReduction <= 0 and dCurrMachReduction > 0) then + ToolInfo.idTool = nCurrIndex + ToolInfo.dMaxMatReduction = dCurrMachReduction + -- altrimenti scelgo il migliore + else + -- se entrambi completi + if ToolInfo.dMaxMatReduction < 0 and dCurrMachReduction < 0 then + -- scelgo utensile con rapporto lunghezza / diametro minore + if ( TOOLS[nCurrIndex].dLength / TOOLS[nCurrIndex].dDiameter) < ( TOOLS[ToolInfo.idTool].dLength / TOOLS[ToolInfo.idTool].dDiameter) then + ToolInfo.idTool = nCurrIndex + ToolInfo.dMaxMatReduction = dCurrMachReduction + end + -- se entrambi incompleti + elseif ToolInfo.dMaxMatReduction < 0 and dCurrMachReduction < 0 then + --scelgo quello che lavora di più + if dCurrMachReduction > ToolInfo.dMaxMatReduction then + ToolInfo.idTool = nCurrIndex + ToolInfo.dMaxMatReduction = dCurrMachReduction + end + end + end + end + + end + return ToolInfo end ------------------------------------------------------------------------------------------------------------- diff --git a/Process.lua b/Process.lua index 04b5467..ab06601 100644 --- a/Process.lua +++ b/Process.lua @@ -86,7 +86,7 @@ local function MyProcessInputData() end end if not bFound then - table.insert( vBeam, { Ind = #vBeam + 1, Id = nPartId, Name = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) + table.insert( vBeam, { nInd = #vBeam + 1, Id = nPartId, sName = ( EgtGetName( nPartId) or ( 'Id=' .. tonumber( nPartId)))}) end end nId = EgtGetNextSelectedObj() @@ -97,7 +97,7 @@ local function MyProcessInputData() else local sOut = '' for i = 1, #vBeam do - sOut = sOut .. vBeam[i].Name .. ', ' + sOut = sOut .. vBeam[i].sName .. ', ' end sOut = sOut:sub( 1, -3) EgtOutLog( 'Travi selezionate : ' .. sOut, 1) @@ -108,18 +108,18 @@ local function MyProcessInputData() local Ls = EgtGetFirstNameInGroup( vBeam[i].Id, 'Box') local b3Solid = EgtGetBBoxGlob( Ls or GDB_ID.NULL, GDB_BB.STANDARD) if not b3Solid then - EgtOutBox( 'Box non definito per la trave ' .. vBeam[i].Name, 'Lavora Travi', 'ERROR') + EgtOutBox( 'Box non definito per la trave ' .. vBeam[i].sName, 'Lavora Travi', 'ERROR') return false else - vBeam[i].Box = b3Solid + vBeam[i].b3Box = b3Solid end end - dRawW = vBeam[1].Box:getDimY() - dRawH = vBeam[1].Box:getDimZ() + dRawW = vBeam[1].b3Box:getDimY() + dRawH = vBeam[1].b3Box:getDimZ() local vBeamErr = {} for i = 2, #vBeam do - local dDimW = vBeam[i].Box:getDimY() - local dDimH = vBeam[i].Box:getDimZ() + local dDimW = vBeam[i].b3Box:getDimY() + local dDimH = vBeam[i].b3Box:getDimZ() if ( abs( dDimW - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 10 * GEO.EPS_SMALL) and ( abs( dDimH - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 10 * GEO.EPS_SMALL) then table.insert( vBeamErr, i) @@ -128,7 +128,7 @@ local function MyProcessInputData() if #vBeamErr > 0 then local sOut = 'Rimosse travi con sezioni diverse dalla prima :\n' for i = #vBeamErr, 1, -1 do - sOut = sOut .. vBeam[vBeamErr[i]].Name .. '\n' + sOut = sOut .. vBeam[vBeamErr[i]].sName .. '\n' EgtDeselectPartObjs( vBeam[vBeamErr[i]].Id) table.remove( vBeam, vBeamErr[i]) end @@ -166,15 +166,15 @@ local function MyProcessBeams() -- Lunghezza totale delle travi local dTotLen = 0 for i = 1, #vBeam - 1 do - dTotLen = dTotLen + vBeam[i].Box:getDimX() + dTotLen = dTotLen + vBeam[i].b3Box:getDimX() end - dTotLen = dTotLen + max( vBeam[#vBeam].Box:getDimX(), BeamData.MinRaw) + dTotLen = dTotLen + max( vBeam[#vBeam].b3Box:getDimX(), BeamData.dMinRaw) local dAddLen = BeamData.OVM_HEAD + ( #vBeam - 1) * BeamData.OVM_MID - EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BeamData.MinRaw + BeamData.OVM_MID, 1), 1) + EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BeamData.dMinRaw + BeamData.OVM_MID, 1), 1) -- Richiedo lunghezza del grezzo, sovramateriale di testa, forzatura verticale e ordinamento automatico secondo la lunghezza local vsVal = EgtDialogBox( 'Lavora Travi' .. ' (Ltot='..EgtNumToString( dTotLen + dAddLen + 0.5, 0).. - ', Lmax='..EgtNumToString( BeamData.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BeamData.MinRaw + BeamData.OVM_MID, 0)..')', + ', Lmax='..EgtNumToString( BeamData.MAX_RAW, 0)..',MinUlr='..EgtNumToString( BeamData.dMinRaw + BeamData.OVM_MID, 0)..')', {'Lunghezza grezzo', EgtNumToString( BeamData.STD_RAW, 0)}, {'Sovramateriale di testa', EgtNumToString( BeamData.OVM_HEAD, 0)}, {'Offset intermedio', EgtNumToString( BeamData.OVM_MID, 0)}, @@ -256,17 +256,17 @@ local function MyProcessBeams() local bOrd = ( vsVal[5] == 'true') if bOrd then table.sort( vBeam, function( B1, B2) - if abs( B1.Box:getDimX() - B2.Box:getDimX()) < 1 then - return B1.Ind < B2.Ind + if abs( B1.b3Box:getDimX() - B2.b3Box:getDimX()) < 1 then + return B1.nInd < B2.nInd else - return B1.Box:getDimX() < B2.Box:getDimX() + return B1.b3Box:getDimX() < B2.b3Box:getDimX() end end) end do local sOut = '' for i = 1, #vBeam do - sOut = sOut .. vBeam[i].Name .. ', ' + sOut = sOut .. vBeam[i].sName .. ', ' end sOut = sOut:sub( 1, -3) EgtOutLog( 'Travi ordinate : ' .. sOut, 1) @@ -292,16 +292,16 @@ local function MyProcessFeatures() local nWarnCnt = 0 local sOutput = '' for i = 1, #Stats do - if Stats[i].Err > 0 then + if Stats[i].nErr > 0 then nErrCnt = nErrCnt + 1 - sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) - elseif Stats[i].Err < 0 then + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].idCut, Stats[i].idTask, Stats[i].sMsg) + elseif Stats[i].nErr < 0 then -- se segnalazione scarico pezzo standard, incompleto o a caduta - if Stats[i].Err == -100 or Stats[i].Err == -101 or Stats[i].Err == -102 then + if Stats[i].nErr == -100 or Stats[i].nErr == -101 or Stats[i].nErr == -102 then -- non faccio niente else nWarnCnt = nWarnCnt + 1 - sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].CutId, Stats[i].TaskId, Stats[i].Msg) + sOutput = sOutput .. string.format( '[%d,%d] %s\n', Stats[i].idCut, Stats[i].idTask, Stats[i].sMsg) end end end diff --git a/Strategies/STR0001/STR0001Config.lua b/Strategies/STR0001/STR0001Config.lua index abf82f0..5ac6883 100644 --- a/Strategies/STR0001/STR0001Config.lua +++ b/Strategies/STR0001/STR0001Config.lua @@ -1,12 +1,12 @@ -- Parametri configurabili da cliente per strategia: STR0001 local STR0001Data = { - StrategyId = 'STR0001', + sStrategyId = 'STR0001', Parameters = { - { Name = 'OverMatOnLenght', Value = '0', Description = 'Sovramateriale lunghezza tenone', Type = 'd'}, - { Name = 'OverMatOnRadius', Value = '0', Description = 'Sovramateriale larghezza tenone', Type = 'd'}, - { Name = 'MaxMillingPaths', Value = '3', Description = 'Numero massimo di passaggi di fresatura. Se richiesti più passaggi, si fa svuotatura', Type = 'd'}, - { Name = 'UseDTToolOnPocketing', Value = 'true', Description = 'Utilizza utensile a coda di rondimne per fare svuotatura', Type = 'b'} + { sName = 'dOverMatOnLenght', sValue = '0', sDescription = 'Sovramateriale lunghezza tenone', sType = 'd'}, + { sName = 'dOverMatOnRadius', sValue = '0', sDescription = 'Sovramateriale larghezza tenone', sType = 'd'}, + { sName = 'nMaxMillingPaths', sValue = '3', sDescription = 'Numero massimo di passaggi di fresatura. Se richiesti più passaggi, si fa svuotatura', sType = 'd'}, + { sName = 'bUseDTToolOnPocketing', sValue = 'true', sDescription = 'Utilizza utensile a coda di rondimne per fare svuotatura', sType = 'b'} } } diff --git a/Strategies/STR0002/STR0002.lua b/Strategies/STR0002/STR0002.lua index f7d9c39..7507fc8 100644 --- a/Strategies/STR0002/STR0002.lua +++ b/Strategies/STR0002/STR0002.lua @@ -14,6 +14,7 @@ -- carico librerie local BeamLib = require( 'BeamLib') local MachLib = require( 'MachiningLib') +local FeatureData = require( 'FeatureData') -- Tabella per definizione modulo local STR0002 = {} @@ -21,7 +22,7 @@ local Strategy = {} ------------------------------------------------------------------------------------------------------------- local function IsTopologyOk( Proc) - if Proc.Topology.Name == 'Pocket-5-Blind' then + if Proc.Topology.sName == 'Pocket-5-Blind' then return true else return false @@ -33,42 +34,49 @@ function STR0002.Make( AddMachining, 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') - Strategy.Name = StrategyLib.Config.StrategyId + Strategy.sName = StrategyLib.Config.sStrategyId CustomParameters = BeamLib.GetUpdateCustomParameters( CustomParameters, StrategyLib.Config.Parameters) Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( CustomParameters) + Strategy.RatingResult = {} if not IsTopologyOk( Proc) then - local sErr = 'Feature '.. Proc.FeatureId .. ' : strategy ' .. Strategy.Config.StrategyId .. ' not implemented' + local sErr = 'Feature '.. Proc.idFeature .. ' : strategy ' .. Strategy.Config.sStrategyId .. ' not implemented' EgtOutLog( sErr) return false, sErr end -- TODO fare calcolo per decidere se spezzare - - local Tool = {} + + local ToolInfo = {} -- serve utensile che possa lavorare di testa - local sTypeMill = 'MILL_STD' - local dMaxToolDiameter = min( Strategy.Parameters.MaxCornerRadius * 2, Proc.MainFaces.BottomFace.Height, Proc.MainFaces.BottomFace.Width) + local sMillType = 'MILL_STD' + local sMillShape = 'STANDARD' + local dMaxToolDiameter = min( Strategy.Parameters.dMaxCornerRadius * 2, Proc.MainFaces.BottomFace.dHeight, Proc.MainFaces.BottomFace.dWidth) + local dElevation = Proc.MainFaces.BottomFace.dElevation -- TODO cercare utensile appropriato - -- Tool = MachLib.FindMill( sTypeMill, dMaxToolDiameter) - - if Tool then - Strategy.RatingResult.Status = 'Completed' - Strategy.RatingResult.Rating = FeatureData.GetFeatureRating( 'Mill', 100) - Strategy.RatingResult.CompletionIndex = 5 - Strategy.RatingResult.Info = '' + ToolInfo = MachLib.FindMill( Proc, sMillType, sMillShape, dMaxToolDiameter, dElevation, Proc.MainFaces.BottomFace.vtN) + + if TOOLS[ToolInfo.idTool].sName then + if ToolInfo.dMaxMatReduction < 0 then + Strategy.RatingResult.sStatus = 'Not-Completed' + else + Strategy.RatingResult.sStatus = 'Completed' + end + Strategy.RatingResult.dCompletionIndex = min( 100, ( ( dElevation + ToolInfo.dMaxMatReduction) / dElevation) * 100) + Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'Mill', Strategy.RatingResult.dCompletionIndex) + Strategy.RatingResult.sInfo = '' else - Strategy.RatingResult.Status = 'Not-Applicable' - Strategy.RatingResult.Rating = FeatureData.GetFeatureRating( 'None', 0) - Strategy.RatingResult.CompletionIndex = 0 - Strategy.RatingResult.Info = 'Mill not found' + Strategy.RatingResult.sStatus = 'Not-Applicable' + Strategy.RatingResult.dCompletionIndex = 0 + Strategy.RatingResult.dRating = FeatureData.GetFeatureRating( 'None', Strategy.RatingResult.dCompletionIndex) + Strategy.RatingResult.sInfo = 'Mill not found' end -- se richiesto applico lavorazione if AddMachining then - EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, 'Fresa25x130') + EgtCreateMachining( 'Svuotatura', MCH_OY.POCKETING, TOOLS[ToolInfo.idTool].sName) end return Strategy.RatingResult diff --git a/Strategies/STR0002/STR0002Config.lua b/Strategies/STR0002/STR0002Config.lua index 56636a4..345605c 100644 --- a/Strategies/STR0002/STR0002Config.lua +++ b/Strategies/STR0002/STR0002Config.lua @@ -1,9 +1,9 @@ -- Parametri configurabili da cliente per strategia: STR0002 local STR0002Data = { - StrategyId = 'STR0002', + sStrategyId = 'STR0002', Parameters = { - { Name = 'MaxCornerRadius', Value = '15', Description = 'Affondamento lavorazione', Type = 'd'} + { sName = 'dMaxCornerRadius', sValue = '15', sDescription = 'Affondamento lavorazione', sType = 'd'} } }