Files
databeamnew/Strategies/Standard/STR0005/STR0005.lua
T
luca.mazzoleni 7b12eaf331 - in BatchProcessNew -> GET_TOPOLOGY si legge anche nParts (serve nel Classify Topology)
- in STR0005 si ammettono feature a più di 3 lati se la topologia è DoubleBevel
- in BLADEKEEPWASTE si gestisce topologia DoubleBevel e migliorie varie
2026-03-06 12:42:53 +01:00

222 lines
9.7 KiB
Lua

-- Strategia: STR0005
-- Descrizione
-- lama per taglio facce lasciando codolo o con cubetti
-- Feature: cut, longcut, ridgelap, ...
-- carico librerie
local BeamLib = require( 'BeamLib')
local BeamData = require( 'BeamDataNew')
local MachiningLib = require( 'MachiningLib')
local FeatureLib = require( 'FeatureLib')
-- strategie di base
local BladeToWaste = require( 'BLADETOWASTE')
local BladeKeepWaste = require( 'BLADEKEEPWASTE')
-- Tabella per definizione modulo
local STR0005 = {}
local Strategy = {}
local Blade = {}
Blade.Result = {}
-------------------------------------------------------------------------------------------------------------
local function IsTwoFacesCommonEdgeTooLong( Proc, Part)
local bIsTwoFacesCommonEdgeTooLong = false
-- controlli preventivi
if Proc.nFct ~= 2 then
error('IsTwoFacesCommonEdgeTooLong : feature must have two faces ')
end
-- ricerca lato in comune
local nCommonEdge
for i = 1, #Proc.Faces[1].Edges do
if Proc.Faces[1].Edges[i].idAdjacentFace > -1 then
nCommonEdge = i
end
end
-- se due facce, cubetti troppo lunghi in X non si possono fare
local ptEdge1, ptEdge2 = Proc.Faces[1].Edges[nCommonEdge].ptStart, Proc.Faces[1].Edges[nCommonEdge].ptEnd
local b3BoxEdge = BBox3d( ptEdge1, ptEdge2)
local dEdgeLengthOnX = b3BoxEdge:getDimX()
if FeatureLib.IsMachiningLong( dEdgeLengthOnX, Part) then
bIsTwoFacesCommonEdgeTooLong = true
end
return bIsTwoFacesCommonEdgeTooLong
end
-------------------------------------------------------------------------------------------------------------
function STR0005.Make( bAddMachining, Proc, Part, CustomParameters)
-- carico parametri da default e li aggiorno con quelli passati dal chiamante (potrebbero non essere congruenti)
local StrategyLib = {}
StrategyLib.Config = STRATEGIES_CONFIG[CustomParameters.sStrategyId]
Strategy.sName = StrategyLib.Config.sStrategyId
Strategy.Parameters = BeamLib.LoadCustomParametersInStrategy( Proc, Part, CustomParameters, StrategyLib.Config)
Strategy.Result = {}
Strategy.Result.sInfo = ''
Blade.Result = {}
local AuxiliaryData = { bIgnoreNotClampableLength = false}
local dTimeToMachine = 0
local dMRRBlade = 0
local dCompletionPercentage = 0
local dQuality = 0
local dMRRBladeAddedFace = 0
local dCompletionPercentageAddedFace = 0
local dQualityAddedFace = 0
-- più di 3 facce non supportate
if Proc.nFct > 3 and ( not Proc.Topology.sFamily == 'DoubleBevel') then
Strategy.Result = FeatureLib.GetStrategyResultNotApplicable( 'More than 3 faces not supported')
end
-- estensione oltre la coda
local dExtendAfterTail = Strategy.Parameters.dExtendAfterTail or max( Part.dDistanceToNextPiece, 0)
if MachiningLib.CanExtendAfterTail( Strategy.Parameters.sCanDamageNextPiece, Part) then
dExtendAfterTail = 10000
end
-- disambiguazione caso 3 facce tipo RidgeLap
local idAddedTmFace
local nAddedFace
if Proc.nFct == 3 and not Proc.Topology.sName == 'Groove-3-Through' then
if Proc.AdjacencyMatrix[2][3] < 0 then
nAddedFace = 1 - 1
elseif Proc.AdjacencyMatrix[1][3] < 0 then
nAddedFace = 2 - 1
else
nAddedFace = 3 - 1
end
-- recupero gruppo per geometria addizionale
local nAddGrpId = BeamLib.GetAddGroup( Part.id)
-- faccia aggiuntiva da lavorare
idAddedTmFace = EgtCopySurfTmFacet( Proc.id, nAddedFace, nAddGrpId)
-- rimozione della terza faccia dalla Proc
local idNewProc = EgtCopyGlob( Proc.id, nAddGrpId)
EgtSurfTmRemoveFacet( idNewProc, nAddedFace)
Proc = FeatureLib.GetProcFromTrimesh( idNewProc, Part, Proc)
end
-- considerazioni necessarie a determinare se lavorare con codolo oppure no
local bKeepWasteAttached = ( Strategy.Parameters.sCuttingStrategy == 'KEEP_WASTE_ATTACHED')
local bDropWaste = ( Strategy.Parameters.sCuttingStrategy == 'DROP_WASTE')
local bFeatureHindersClamping = MachiningLib.IsFeatureHinderingClamping( Proc, Part)
local bIsFeatureLong = FeatureLib.IsMachiningLong( Proc.b3Box:getDimX(), Part, { dMaxSegmentLength = BeamData.LONGCUT_ENDLEN})
local bIsTwoFacesCommonEdgeTooLong = ( ( Proc.Topology and ( Proc.Topology.sName == 'Rabbet-2-Through' or Proc.Topology.sName == 'Bevel-2-Blind')) and IsTwoFacesCommonEdgeTooLong( Proc, Part))
-- lavorazione con codolo
if ( Proc.nFct > 2 and bIsFeatureLong)
or ( bFeatureHindersClamping and not bDropWaste)
or bKeepWasteAttached then
local BladeKeepWasteResult
local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth, bForced = bKeepWasteAttached}
AuxiliaryData.bIgnoreNotClampableLength = true
Blade.Result, BladeKeepWasteResult = BladeKeepWaste.Make( Proc, Part, OptionalParameters)
dTimeToMachine = BladeKeepWasteResult.dTimeToMachine
dMRRBlade = BladeKeepWasteResult.dMRR
dCompletionPercentage = BladeKeepWasteResult.dCompletionPercentage
dQuality = BladeKeepWasteResult.dQuality
Strategy.Result.sInfo = BladeKeepWasteResult.sInfo or ''
end
-- lavorazione a cubetti / taglio singolo
if #Blade.Result == 0
and Proc.nFct < 3
and not bKeepWasteAttached
and not bIsTwoFacesCommonEdgeTooLong then
AuxiliaryData.bIgnoreNotClampableLength = false
local BladeToWasteResult
local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume,
dMaxWasteLength = Strategy.Parameters.dMaxWasteLength,
bSaveAddedGeometries = bAddMachining,
dExtendAfterTail = dExtendAfterTail,
bAllowFastCuts = Strategy.Parameters.bAllowFastCuts,
bReduceBladePath = Strategy.Parameters.bReduceBladePath,
bDisableDicing = Strategy.Parameters.bDisableDicing
}
Blade.Result, BladeToWasteResult = BladeToWaste.Make( Proc, Part, OptionalParameters)
dTimeToMachine = BladeToWasteResult.dTimeToMachine
dMRRBlade = BladeToWasteResult.dMRR
dCompletionPercentage = BladeToWasteResult.dCompletionPercentage
dQuality = BladeToWasteResult.dQuality
end
-- se arrivati qui non è stata ancora applicata alcuna lavorazione, si prova la lavorazione con codolo
if #Blade.Result == 0 and not bDropWaste then
local BladeKeepWasteResult
local OptionalParameters = { dExtendAfterTail = dExtendAfterTail, dStripWidth = Strategy.Parameters.dStripWidth,
dMillingOffsetFromSide = Strategy.Parameters.dMillingOffsetFromSide
}
AuxiliaryData.bIgnoreNotClampableLength = true
Blade.Result, BladeKeepWasteResult = BladeKeepWaste.Make( Proc, Part, OptionalParameters)
dTimeToMachine = BladeKeepWasteResult.dTimeToMachine
dMRRBlade = BladeKeepWasteResult.dMRR
dCompletionPercentage = BladeKeepWasteResult.dCompletionPercentage
dQuality = BladeKeepWasteResult.dQuality
end
-- lavorazione eventuale terza faccia tipo RidgeLap
-- TODO da completare
-- TODO va messa per prima????????
if idAddedTmFace then
local BladeToWasteResult
local OptionalParameters = { dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume,
dMaxWasteLength = Strategy.Parameters.dMaxWasteLength,
bSaveAddedGeometries = bAddMachining,
dExtendAfterTail = dExtendAfterTail
}
Blade.Result, BladeToWasteResult = BladeToWaste.Make( idAddedTmFace, Part, OptionalParameters)
-- TODO calcolo risultati da aggiornare con funzioni nuove
dMRRBladeAddedFace = BladeToWasteResult.dMRR
dCompletionPercentageAddedFace = BladeToWasteResult.dCompletionPercentage
dQualityAddedFace = BladeToWasteResult.dQuality
dTimeToMachine = dTimeToMachine + BladeToWasteResult.dTimeToMachine
-- la faccia aggiuntiva conta per 1/3
dMRRBlade = 2/3 * dMRRBlade + 1/3 * dMRRBladeAddedFace
dCompletionPercentage = 2/3 * dCompletionPercentage + 1/3 * dCompletionPercentageAddedFace
dQuality = 2/3 * dQuality + 1/3 * dQualityAddedFace
end
-- aggiunta lavorazioni
local nIsApplicableCount = 0
local bAreAllMachiningsAdded = true
for i = 1, #Blade.Result do
if Blade.Result[i].bIsApplicable then
nIsApplicableCount = nIsApplicableCount + 1
if bAddMachining then
local bIsMachiningAdded = MachiningLib.AddMachinings( Proc, Blade.Result[i], AuxiliaryData)
if not bIsMachiningAdded then
bAreAllMachiningsAdded = false
end
end
Strategy.Result.sInfo = Strategy.Result.sInfo .. '\n' .. Blade.Result[i].sMessage
end
end
-- TODO migliorare calcolo area lavorata; se ho il codolo ha senso l'incompleta? se incompleta con codolo faccio i cubetti??
-- TODO settare che il codolo restituisce incompleta tranne quando è forzato
if nIsApplicableCount > 0 then
if dCompletionPercentage > 100 - 10 * GEO.EPS_SMALL then
Strategy.Result.sStatus = 'Completed'
else
Strategy.Result.sStatus = 'Not-Completed'
end
else
Strategy.Result.sStatus = 'Not-Applicable'
end
Strategy.Result.dCompletionIndex = FeatureLib.GetFeatureCompletionIndex( dCompletionPercentage)
Strategy.Result.dQuality = dQuality
Strategy.Result.dTimeToMachine = dTimeToMachine
Strategy.Result.dMRR = dMRRBlade
return bAreAllMachiningsAdded, Strategy.Result
end
-------------------------------------------------------------------------------------------------------------
return STR0005