diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index 9238635..20fb632 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -65,6 +65,43 @@ function BeamLib.AddPartEndFace( PartId, b3Solid) return true end +------------------------------------------------------------------------------------------------------------- +function BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sSide) + local _sSide = sSide or '' + + -- il box del grezzo contiene sempre il sovramateriale di testa + if _sSide == 'Head' then + + local b3WithHead = BBox3d( Part.b3Raw) + return b3WithHead + + -- per aggiungere il materiale di coda si aggiunge il box dell'eventuale grezzo successivo + elseif _sSide == 'Tail' then + + local b3WithTail = BBox3d( Part.b3Part) + local nNextRawId = EgtGetNextRawPart( Part.idRaw) + if nNextRawId then + local b3Tail = EgtGetRawPartBBox( nNextRawId) + b3WithTail:Add( b3Tail) + end + + return b3WithTail + + -- per aggiungere entrambi si procede come per la coda ma partendo dal box del grezzo, che già contiene la testa + else + + local b3WithHeadTail = BBox3d( Part.b3Raw) + local nNextRawId = EgtGetNextRawPart( Part.idRaw) + if nNextRawId then + local b3Tail = EgtGetRawPartBBox( nNextRawId) + b3WithHeadTail:Add( b3Tail) + end + + return b3WithHeadTail + + end +end + ------------------------------------------------------------------------------------------------------------- function BeamLib.GetPartSplittingPoints( Part) local PartSplittingPoints = {} diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index aa70c25..13debb8 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -941,6 +941,7 @@ function FeatureLib.CalculateFeatureNotClampableLengths( Proc, Part) local dNotClampableLengthTail = 0 -- se il grezzo non è definito, prendo il box del pezzo + -- TODO 1- si sta passando b3part per riferimento, 2- non dovrebbe essre sempre definito? if not Part.b3Raw then Part.b3Raw = Part.b3Part end diff --git a/LuaLibs/LeadInOutLib.lua b/LuaLibs/LeadInOutLib.lua index 93cf9f7..6e70d3f 100644 --- a/LuaLibs/LeadInOutLib.lua +++ b/LuaLibs/LeadInOutLib.lua @@ -8,6 +8,7 @@ local LeadInOutLib = {} require( 'EgtBase') local BeamData = require( 'BeamDataNew') local FaceData = require( 'FaceData') +local BeamLib = require( 'BeamLib') EgtOutLog( ' LeadInOutLib started', 1) @@ -99,7 +100,7 @@ end ------------------------------------------------------------------------------------------------------------- -function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters) +function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters, OptionalParameters) -- parametri obbligatori local Face = Parameters.Face @@ -108,6 +109,11 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters) local Tool = Parameters.Tool local dDepthToMachine = Parameters.dDepthToMachine + -- parametri opzionali + local sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation or 'Tail' + local bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength or false + local bMoveAfterSplit = OptionalParameters.bMoveAfterSplit or false + local LeadInOut = {} local bIsStartClosed = not Edge.bIsStartOpen local bIsEndClosed = not Edge.bIsEndOpen @@ -159,8 +165,18 @@ function LeadInOutLib.CalculateLeadInOut( sLeadInOutType, Parameters) local ptEndBladeCenter = ptEndAtDepth + Edge.vtN * Tool.dDiameter / 2 -- box per calcolo uscita lama + -- se è un taglio di testa o coda oppure se di coda e non si sposta dopo separazione va aggiunto il sovramateriale + local b3BoxPartExpanded = BBox3d( Part.b3Part) + if bCannotSplitRestLength or ( not bMoveAfterSplit) then + if ( sRestLengthSideForPreSimulation == 'Head') or Part.bIsLastPart then + b3BoxPartExpanded = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation) + elseif sRestLengthSideForPreSimulation == 'Tail' then + local ptPointAtRestLength = Point3d( b3BoxPartExpanded:getMin():getX() - Part.dRestLength, b3BoxPartExpanded:getMin():getY(), b3BoxPartExpanded:getMin():getZ()) + b3BoxPartExpanded:Add( ptPointAtRestLength) + end + end -- il box si espande in tutte le direzioni per contemplare la sicurezza CUT_SIC - local b3BoxPartExpanded = BBox3d( Part.b3Part) ; b3BoxPartExpanded:expand( BeamData.CUT_SIC) + b3BoxPartExpanded:expand( BeamData.CUT_SIC) -- calcolo attacco scelto if sLeadInOutType == 'Perpendicular' then diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index df71dfb..ebe0ba2 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -350,9 +350,14 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) -- calcolo e check attacchi local LeadInOut = {} + local LeadInOutOptionalParameters = { + sRestLengthSideForPreSimulation = OptionalParameters.sRestLengthSideForPreSimulation, + bCannotSplitRestLength = OptionalParameters.bCannotSplitRestLength, + bMoveAfterSplit = bMoveAfterSplit + } -- attacco perpendicolare - local PerpendicularLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Perpendicular', Parameters) + local PerpendicularLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Perpendicular', Parameters, LeadInOutOptionalParameters) -- check extracorsa nei punti di attacco PointsOnToolTipCenter = { @@ -376,7 +381,7 @@ local function TestEngagement( sBladeEngagement, Parameters, OptionalParameters) end -- attacco tangenziale - local TangentLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Tangent', Parameters) + local TangentLeadInOut = LeadInOutLib.CalculateLeadInOut( 'Tangent', Parameters, LeadInOutOptionalParameters) -- check extracorsa nei punti di attacco PointsOnToolTipCenter = { PreSimulationLib.GetPointOnToolTipCenter( TangentLeadInOut.LeadIn.ptPoint, vtHead, Face.vtN, Edge.vtN, Tool), diff --git a/LuaLibs/PreSimulationLib.lua b/LuaLibs/PreSimulationLib.lua index 84cc3ad..a08a3b5 100644 --- a/LuaLibs/PreSimulationLib.lua +++ b/LuaLibs/PreSimulationLib.lua @@ -69,15 +69,15 @@ end local function GetRestlengthSurfTm( Part, sRestLengthSideForPreSimulation) -- si costruisce il box in globale - local b3RestLength = BBox3d() - if sRestLengthSideForPreSimulation == 'Tail' then - local ptRestLengthMax = Point3d( Part.b3Part:getMin()) + X_AX() * 500 * GEO.EPS_SMALL - local ptRestLengthMin = Point3d( Part.b3Part:getMin():getX() - Part.dRestLength, Part.b3Part:getMax():getY(), Part.b3Part:getMax():getZ()) - b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax) - elseif sRestLengthSideForPreSimulation == 'Head' then - local ptRestLengthMin = Point3d( Part.b3Part:getMax() - X_AX() * 500 * GEO.EPS_SMALL) - local ptRestLengthMax = Point3d( Part.b3Part:getMaX():getX() + Part.dHeadOverMaterial, Part.b3Part:getMin():getY(), Part.b3Part:getMin():getZ()) - b3RestLength = BBox3d( ptRestLengthMin, ptRestLengthMax) + local b3RestLength + if ( sRestLengthSideForPreSimulation == 'Head') or Part.bIsLastPart then + b3RestLength = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, sRestLengthSideForPreSimulation) + elseif sRestLengthSideForPreSimulation == 'Tail' then + b3RestLength = BBox3d( Part.b3Part) + local ptPointAtRestLength = Point3d( b3RestLength:getMin():getX() - Part.dRestLength, b3RestLength:getMin():getY(), b3RestLength:getMin():getZ()) + b3RestLength:Add( ptPointAtRestLength) + else + b3RestLength = BBox3d( Part.b3Part) end -- si crea la trimesh dal box diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index c1bdd59..927cbf5 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -92,18 +92,16 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) end if not bExecutePrecutOnly then - local OptionalParameters = {} - -- si parte dal box della feature e si aggiunge il punto estremo del grezzo - local b3BoxDicing = BBox3d( Proc.b3Box) - b3BoxDicing:Add( Part.b3Raw:getMax()) - b3BoxDicing:expand( 1000 * GEO.EPS_SMALL) - OptionalParameters.b3BoxDicing = b3BoxDicing + local OptionalParametersBladeToWaste = {} - OptionalParameters.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume - OptionalParameters.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength - OptionalParameters.bReduceBladePath = Strategy.Parameters.bReduceBladePath + OptionalParametersBladeToWaste.b3BoxDicing = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, 'Head') + OptionalParametersBladeToWaste.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume + OptionalParametersBladeToWaste.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength + OptionalParametersBladeToWaste.bReduceBladePath = Strategy.Parameters.bReduceBladePath + OptionalParametersBladeToWaste.sRestLengthSideForPreSimulation = 'Head' + OptionalParametersBladeToWaste.bCannotSplitRestLength = true - Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParameters) + Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParametersBladeToWaste) if Strategy.Machining and #Strategy.Machining > 0 then for i = 1, #Strategy.Machining do local TempList = {} diff --git a/Strategies/Standard/TAILCUT/TAILCUT.lua b/Strategies/Standard/TAILCUT/TAILCUT.lua index f2d5f56..030d573 100644 --- a/Strategies/Standard/TAILCUT/TAILCUT.lua +++ b/Strategies/Standard/TAILCUT/TAILCUT.lua @@ -122,21 +122,16 @@ function TAILCUT.Make( bAddMachining, Proc, Part, CustomParameters) end if not bExecutePrecutOnly then - OptionalParameters = {} + local OptionalParametersBladeToWaste = {} - -- eventuale grezzo custom per dicing (grezzo attuale + grezzo di coda) - local nNextRawId = EgtGetNextRawPart( Part.idRaw) - if nNextRawId then - local b3BoxDicing = EgtGetRawPartBBox( nNextRawId) - b3BoxDicing:Add( Part.b3Raw) - OptionalParameters.b3BoxDicing = b3BoxDicing - end + OptionalParametersBladeToWaste.b3BoxDicing = BeamLib.GetPartBoxWithHeadTailOvermaterial( Part, 'Tail') + OptionalParametersBladeToWaste.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume + OptionalParametersBladeToWaste.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength + OptionalParametersBladeToWaste.bReduceBladePath = Strategy.Parameters.bReduceBladePath + OptionalParametersBladeToWaste.sRestLengthSideForPreSimulation = 'Tail' + OptionalParametersBladeToWaste.bCannotSplitRestLength = true - OptionalParameters.dMaxWasteVolume = Strategy.Parameters.dMaxWasteVolume - OptionalParameters.dMaxWasteLength = Strategy.Parameters.dMaxWasteLength - OptionalParameters.bReduceBladePath = Strategy.Parameters.bReduceBladePath - - Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParameters) + Strategy.Machining, _ = BladeToWaste.Make( Proc, Part, OptionalParametersBladeToWaste) if Strategy.Machining and #Strategy.Machining > 0 then for i = 1, #Strategy.Machining do local TempList = {} diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index feccbed..3270c67 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -592,12 +592,14 @@ local function GetDualSideCutStrategy( Proc, Part, OptionalParameters) Edge = EdgeToMachineOpposite, Part = Part, Tool = TOOLS[ToolInfo.nToolIndex], - dDepthToMachine = dDepthToMachine, + dDepthToMachine = dDepthToMachine + } + local BladeEngagementOptionalParameters = { sRestLengthSideForPreSimulation = sRestLengthSideForPreSimulation, bCannotSplitRestLength = bCannotSplitRestLength } TIMER:startElapsed( 'GetBladeEngagement') - local bIsApplicableOpposite = MachiningLib.GetBladeEngagement( BladeEngagementParameters) + local bIsApplicableOpposite = MachiningLib.GetBladeEngagement( BladeEngagementParameters, BladeEngagementOptionalParameters) TIMER:stopElapsed( 'GetBladeEngagement') if not bIsApplicableOpposite then return CuttingParametersList, EdgeToMachine diff --git a/StrategyLibs/FACEBYBLADE.lua b/StrategyLibs/FACEBYBLADE.lua index a503791..389b2aa 100644 --- a/StrategyLibs/FACEBYBLADE.lua +++ b/StrategyLibs/FACEBYBLADE.lua @@ -548,7 +548,7 @@ function FACEBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar end -- solo per debug - --Cutting.nOutRaw = 3 + Cutting.nOutRaw = 3 -- lunghezza lavorata -- TODO per il calcolo del dLengthOnX si deve correggere con allungamento / accorciamento percorso