diff --git a/StrategyLibs/BLADETOWASTE.lua b/StrategyLibs/BLADETOWASTE.lua index 430bd6a..ff8dfd2 100644 --- a/StrategyLibs/BLADETOWASTE.lua +++ b/StrategyLibs/BLADETOWASTE.lua @@ -273,7 +273,7 @@ local function GetBestBlade( Proc, Part, Face, OptionalParameters) nToolIndexBottom = OptionalParameters.nToolIndex end end - -- non ho l'untensile, devo cercarlo e scegliere il migliore tra testa sopra e sotto + -- non ho l'utensile, devo cercarlo e scegliere il migliore tra testa sopra e sotto else local ToolInfo -- ricerca lama testa sopra @@ -753,77 +753,108 @@ local function CutWithDicing( Proc, Part, OptionalParameters) end end -- calcolo lavorazione della singola faccia - for j = 1, #vCuts[i] do - local Cutting = {} - local vtNCurrentFace = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) - local FaceToMachine = { id = 0, vtN = vtNCurrentFace} - -- se taglio DownUp e strato pari composto da 1 o 2 elementi (tutti gli altri casi vengono saltati) - if ( vtNCurrentFace:getZ() < dMinNzDownUp) and ( ( i % 2) == 0) and ( #vCuts[i] <= 2) then - -- il primo elemento prende la direzione prevista, il secondo quella opposta - local vtToolDirectionNew = Vector3d( vtToolDirection) - if j ~= 1 then - vtToolDirectionNew = -vtToolDirection - end - -- lavorazione - local ProcTrimesh = FeatureLib.GetProcFromTrimesh( vCuts[i][j], Part) - local _, Edges = FaceData.GetEdgesInfo( vCuts[i][j], 0) - local EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtToolDirectionNew) - local dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA - local OptionalParametersFaceByBlade = { - dDepthToMachine = dDepthToMachine, - nToolIndex = nToolIndex, - dRadialStepSpan = 0, - dExtendAfterTail = dExtendAfterTail - } - Cutting = FaceByBlade.Make( ProcTrimesh, Part, FaceToMachine, EdgeToMachine, OptionalParametersFaceByBlade) - Cutting.ptCenter = Point3d( ProcTrimesh.Faces[1].ptCenter:getX(), 0, 0) - if Cutting.bIsApplicable then - table.insert( Machinings, Cutting) - else - bIsDicingOk = false - end - if Cutting.sStage == 'AfterTail' then - bMoveAfterSplit = true - end - -- caso generale - else - -- in generale sta sollevato di pochissimo - local dExtraCut = -0.1 - -- se tagli paralleli - if ( i % 2) == 0 then - -- se non ci sono tagli ortogonali devo affondare - if bNoPerpCuts then - dExtraCut = BeamData.CUT_EXTRA - -- se è faccia singola si affonda - elseif Proc.nFct < 2 then - -- se tagli ortogonali invertiti, devo approfondire dello spessore lama - if bAreOrthogonalCutsInverted then - dExtraCut = TOOLS[nToolIndex].dThickness - -- se ultimo taglio, devo affondare - elseif j == #vCuts[i] then - dExtraCut = BeamData.CUT_EXTRA - end + -- per tagli paralleli e faccia aperta si prova a tagliare come se fosse una faccia singola + if ( Proc.nFct == 1) and ( ( i % 2) == 0) then + local nAddGrpId = BeamLib.GetAddGroup( Part.id) + local nSurfToCut = EgtSurfTmBySewing( nAddGrpId, vCuts[i], false) + local ProcTrimesh = FeatureLib.GetProcFromTrimesh( nSurfToCut, Part) + + -- TODO ridurre con bReduceBladePath anche questi tagli? + local OptionalParametersCutWholeWaste = { + nToolIndex = nToolIndex, + dExtendAfterTail = dExtendAfterTail + } + local CutWholeWasteMachinings, CutWholeWasteResult = CutWholeWaste( ProcTrimesh, Part, OptionalParametersCutWholeWaste) + + if CutWholeWasteResult.sStatus == 'Completed' then + for k = 1, #CutWholeWasteMachinings do + table.insert( Machinings, CutWholeWasteMachinings[k]) + if CutWholeWasteMachinings[k].sStage == 'AfterTail' then + bMoveAfterSplit = true end end - local ProcTrimesh = FeatureLib.GetProcFromTrimesh( vCuts[i][j], Part) - local _, Edges = FaceData.GetEdgesInfo( vCuts[i][j], 0) - local EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtToolDirection) - local dDepthToMachine = EdgeToMachine.dElevation + dExtraCut - local OptionalParametersFaceByBlade = { - dDepthToMachine = dDepthToMachine, - nToolIndex = nToolIndex, - dRadialStepSpan = 0, - dExtendAfterTail = dExtendAfterTail - } - Cutting = FaceByBlade.Make( ProcTrimesh, Part, FaceToMachine, EdgeToMachine, OptionalParametersFaceByBlade) - Cutting.ptCenter = Point3d( ProcTrimesh.Faces[1].ptCenter:getX(), 0, 0) - if Cutting.bIsApplicable then - table.insert( Machinings, Cutting) + else + EgtErase( nSurfToCut) + bIsDicingOk = false + end + end + -- per tagli perpendicolari oppure se il taglio a faccia singola non è andato si fanno i tagli standard + if ( i % 2) ~= 0 or not bIsDicingOk then + for j = 1, #vCuts[i] do + local Cutting = {} + local vtNCurrentFace = EgtSurfTmFacetNormVersor( vCuts[i][j], 0, GDB_ID.ROOT) + local FaceToMachine = { id = 0, vtN = vtNCurrentFace} + -- se taglio DownUp e strato pari composto da 1 o 2 elementi (tutti gli altri casi vengono saltati) + if ( vtNCurrentFace:getZ() < dMinNzDownUp) and ( ( i % 2) == 0) and ( #vCuts[i] <= 2) then + -- il primo elemento prende la direzione prevista, il secondo quella opposta + local vtToolDirectionNew = Vector3d( vtToolDirection) + if j ~= 1 then + vtToolDirectionNew = -vtToolDirection + end + -- lavorazione + local ProcTrimesh = FeatureLib.GetProcFromTrimesh( vCuts[i][j], Part) + local _, Edges = FaceData.GetEdgesInfo( vCuts[i][j], 0) + local EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtToolDirectionNew) + local dDepthToMachine = EdgeToMachine.dElevation + BeamData.CUT_EXTRA + local OptionalParametersFaceByBlade = { + dDepthToMachine = dDepthToMachine, + nToolIndex = nToolIndex, + dRadialStepSpan = 0, + dExtendAfterTail = dExtendAfterTail + } + Cutting = FaceByBlade.Make( ProcTrimesh, Part, FaceToMachine, EdgeToMachine, OptionalParametersFaceByBlade) + Cutting.ptCenter = Point3d( ProcTrimesh.Faces[1].ptCenter:getX(), 0, 0) + + if Cutting.bIsApplicable then + table.insert( Machinings, Cutting) + else + bIsDicingOk = false + end + if Cutting.sStage == 'AfterTail' then + bMoveAfterSplit = true + end + -- caso generale else - bIsDicingOk = false - end - if Cutting.sStage == 'AfterTail' then - bMoveAfterSplit = true + -- in generale sta sollevato di pochissimo + local dExtraCut = -0.1 + -- se tagli paralleli + if ( i % 2) == 0 then + -- se non ci sono tagli ortogonali devo affondare + if bNoPerpCuts then + dExtraCut = BeamData.CUT_EXTRA + -- se è faccia singola si affonda + elseif Proc.nFct < 2 then + -- se tagli ortogonali invertiti, devo approfondire dello spessore lama + if bAreOrthogonalCutsInverted then + dExtraCut = TOOLS[nToolIndex].dThickness + -- se ultimo taglio, devo affondare + elseif j == #vCuts[i] then + dExtraCut = BeamData.CUT_EXTRA + end + end + end + local ProcTrimesh = FeatureLib.GetProcFromTrimesh( vCuts[i][j], Part) + local _, Edges = FaceData.GetEdgesInfo( vCuts[i][j], 0) + local EdgeToMachine = BeamLib.FindEdgeBestOrientedAsDirection( Edges, vtToolDirection) + local dDepthToMachine = EdgeToMachine.dElevation + dExtraCut + local OptionalParametersFaceByBlade = { + dDepthToMachine = dDepthToMachine, + nToolIndex = nToolIndex, + dRadialStepSpan = 0, + dExtendAfterTail = dExtendAfterTail + } + Cutting = FaceByBlade.Make( ProcTrimesh, Part, FaceToMachine, EdgeToMachine, OptionalParametersFaceByBlade) + Cutting.ptCenter = Point3d( ProcTrimesh.Faces[1].ptCenter:getX(), 0, 0) + + if Cutting.bIsApplicable then + table.insert( Machinings, Cutting) + bIsDicingOk = true + else + bIsDicingOk = false + end + if Cutting.sStage == 'AfterTail' then + bMoveAfterSplit = true + end end end end