From 217bb4f26eb9a4473fa1b2585cc69e943f0b7b07 Mon Sep 17 00:00:00 2001 From: SaraP Date: Fri, 14 Oct 2022 10:55:20 +0200 Subject: [PATCH] 3dPrinting : - aggiunti coasting e wipe sui setti che non arrivano al bordo. --- LuaLibs/CalcToolPath.lua | 81 +++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/LuaLibs/CalcToolPath.lua b/LuaLibs/CalcToolPath.lua index 8de55bb..1a8a371 100644 --- a/LuaLibs/CalcToolPath.lua +++ b/LuaLibs/CalcToolPath.lua @@ -156,7 +156,7 @@ local function AddLeadIn( nCrvId, LayerParams, nGrpId) EgtInvertCurve( nLeadInCrv) end - if nLeadIn then + if nLeadInCrv then EgtRelocate( nLeadInCrv, nGrpId, GDB_IN.FIRST_SON) EgtModifyCurveExtrusion( nLeadInCrv, LayerParams.vtSlicing, GDB_RT.GLOB) EgtSetInfo( nLeadInCrv, KEY_TYPE, TYPE.LINK) @@ -196,7 +196,7 @@ local function AddLeadOut( nCrvId, LayerParams, nGrpId) end -------------------------------------------------------------------- -local function AddRetraction( nCrvId, LayerParams, dCoastingLen, dWipeLen, dWipeDir) +local function AddRetraction( nCrvId, vtSlicing, dTDiam, dCoastingLen, dWipeLen, dWipeDir) -- recupero i parametri per retrazione local nType = EgtGetInfo( nCrvId, KEY_TYPE, 'i') @@ -224,7 +224,7 @@ local function AddRetraction( nCrvId, LayerParams, dCoastingLen, dWipeLen, dWipe else EgtErase( nCrvId) end - EgtModifyCurveExtrusion( nCoastingId, LayerParams.vtSlicing) + EgtModifyCurveExtrusion( nCoastingId, vtSlicing) EgtSetName( nCoastingId, COASTING_CRV) EgtSetInfo( nCoastingId, KEY_TYPE, TYPE.COASTING) EgtSetColor( nCoastingId, EgtStdColor('ORANGE')) @@ -239,7 +239,7 @@ local function AddRetraction( nCrvId, LayerParams, dCoastingLen, dWipeLen, dWipe EgtTrimCurveEndAtLen( nWipeId, dWipeLen) else - -- se extra shell, infill a zigzag o spiral vase + -- se extra shell, infill a zigzag, spiral vase o rib che non termina sulla parete local vtDir = EgtEV( nCoastingId or nCrvId) local dAng = dWipeDir + s_nDefaultWipeAng -- verifico se necessario cambiare il segno all'angolo @@ -251,20 +251,20 @@ local function AddRetraction( nCrvId, LayerParams, dCoastingLen, dWipeLen, dWipe else bChangeSign = bInverted end - vtDir:rotate( LayerParams.vtSlicing, EgtIf( bChangeSign, - dAng, dAng)) + vtDir:rotate( vtSlicing, EgtIf( bChangeSign, - dAng, dAng)) local ptS = EgtEP( nCoastingId or nCrvId) local ptE = ptS + vtDir * dWipeLen -- verifico soddisfi altezza minima per dimensioni utensile - local dHMin = 0.5 * LayerParams.dTDiam * sqrt( LayerParams.vtSlicing:getX() * LayerParams.vtSlicing:getX() + LayerParams.vtSlicing:getY() * LayerParams.vtSlicing:getY()) + local dHMin = 0.5 * dTDiam * sqrt( vtSlicing:getX() * vtSlicing:getX() + vtSlicing:getY() * vtSlicing:getY()) local k = 1 while ptE:getZ() < dHMin + GEO.EPS_SMALL and k < 36 do - vtDir:rotate( LayerParams.vtSlicing, EgtIf( bChangeSign, 10, -10)) + vtDir:rotate( vtSlicing, EgtIf( bChangeSign, 10, -10)) ptE = ptS + vtDir * dWipeLen k = k + 1 end nWipeId = EgtCurveCompoFromPoints( EgtGetParent( nCrvId), {ptS, ptE}) - EgtModifyCurveExtrusion( nWipeId, LayerParams.vtSlicing, GDB_RT.GLOB) + EgtModifyCurveExtrusion( nWipeId, vtSlicing, GDB_RT.GLOB) EgtRelocateGlob( nWipeId, nCoastingId or nCrvId, GDB_IN.AFTER) end @@ -281,21 +281,21 @@ end local function AddRetractionOnLastCrv( nCrvId, nTpathGrpId, LayerParams, dCoastingLen, dWipeLen, dWipeDir) if LayerParams.nLeadOutType == LEAD_TYPE.NONE then - AddRetraction( nCrvId, LayerParams, dCoastingLen, dWipeLen, dWipeDir) + AddRetraction( nCrvId, LayerParams.vtSlicing, LayerParams.dTDiam, dCoastingLen, dWipeLen, dWipeDir) else local nLeadOutId = EgtGetLastInGroup( nTpathGrpId) local dLen = EgtCurveLength( nLeadOutId) if dLen > dCoastingLen - 500 * GEO.EPS_SMALL then -- coinvolge solo la curva di lead out local dNewCoastingLen = EgtIf( abs( dCoastingLen - dLen) < 500 * GEO.EPS_SMALL, dLen, dCoastingLen) -- verifico se interamente coinvolta - AddRetraction( nLeadOutId, LayerParams, dNewCoastingLen, dWipeLen, dWipeDir) + AddRetraction( nLeadOutId, LayerParams.vtSlicing, LayerParams.dTDiam, dNewCoastingLen, dWipeLen, dWipeDir) else -- coinvolge parte dell'ultima shell crv local dNewCoastingLen = dCoastingLen - dLen - local nCoastingId = AddRetraction( nCrvId, LayerParams, dNewCoastingLen, 0.0, dWipeDir) + local nCoastingId = AddRetraction( nCrvId, LayerParams.vtSlicing, LayerParams.dTDiam, dNewCoastingLen, 0.0, dWipeDir) EgtAddCurveCompoCurve( nCoastingId, nLeadOutId) -- wipe - AddRetraction( nCoastingId, LayerParams, 0, dWipeLen, dWipeDir) + AddRetraction( nCoastingId, LayerParams.vtSlicing, LayerParams.dTDiam, 0, dWipeLen, dWipeDir) end end end @@ -674,35 +674,40 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, d vtE = EgtEV( nCoasting) end EgtErase( nCrvRef) - end - - -- terzo tratto ( diretto verso esterno con ugello chiuso) - if dRibsLOWipe > GEO.EPS_SMALL then - local dAng = dRibsLOWipeAng + s_nDefaultWipeAng - vtE:rotate( vtSlicing, EgtIf( bInvert, - dAng, dAng)) - local ptFinal = ptE + vtE * dRibsLOWipe - -- verifico soddisfi altezza minima per dimensioni utensile - local dHMin = 0.5 * dTDiam * sqrt( vtSlicing:getX() * vtSlicing:getX() + vtSlicing:getY() * vtSlicing:getY()) - local k = 1 - while ptFinal:getZ() < dHMin + GEO.EPS_SMALL and k < 36 do - vtE:rotate( vtSlicing, EgtIf( bInvert, - 10, 10)) - ptFinal = ptE + vtE * dRibsLOWipe - k = k + 1 - end - nWipe = EgtCurveCompoFromPoints( nTPathGrp, { ptE, ptFinal}) - EgtModifyCurveExtrusion( nWipe, vtSlicing, GDB_RT.GLOB) - EgtRelocateGlob( nWipe, nCoasting or nCrvLO or nCrv, GDB_IN.AFTER) - EgtSetName( nWipe, WIPE_CRV) - EgtSetInfo( nWipe, KEY_TYPE, TYPE.WIPE) - EgtSetColor( nWipe, EgtStdColor('AQUA')) + -- terzo tratto ( diretto verso esterno con ugello chiuso) + if dRibsLOWipe > GEO.EPS_SMALL then + local dAng = dRibsLOWipeAng + s_nDefaultWipeAng + vtE:rotate( vtSlicing, EgtIf( bInvert, - dAng, dAng)) + local ptFinal = ptE + vtE * dRibsLOWipe + -- verifico soddisfi altezza minima per dimensioni utensile + local dHMin = 0.5 * dTDiam * sqrt( vtSlicing:getX() * vtSlicing:getX() + vtSlicing:getY() * vtSlicing:getY()) + local k = 1 + while ptFinal:getZ() < dHMin + GEO.EPS_SMALL and k < 36 do + vtE:rotate( vtSlicing, EgtIf( bInvert, - 10, 10)) + ptFinal = ptE + vtE * dRibsLOWipe + k = k + 1 + end + + nWipe = EgtCurveCompoFromPoints( nTPathGrp, { ptE, ptFinal}) + EgtModifyCurveExtrusion( nWipe, vtSlicing, GDB_RT.GLOB) + EgtRelocateGlob( nWipe, nCoasting or nCrvLO or nCrv, GDB_IN.AFTER) + EgtSetName( nWipe, WIPE_CRV) + EgtSetInfo( nWipe, KEY_TYPE, TYPE.WIPE) + EgtSetColor( nWipe, EgtStdColor('AQUA')) + end + else + -- aggiungo coasting e wipe come sulle shell normali + AddRetraction( nCrv, vtSlicing, dTDiam, dRibsLOCoasting, dRibsLOWipe, dRibsLOWipeAng) end - return end nCrvOffs = EgtGetNext( nCrvOffs) end + + -- se non ho trovato curva sul bordo su cui fare il lead out aggiungo coasting e wipe come sulle shell normali + AddRetraction( nCrv, vtSlicing, dTDiam, dRibsLOCoasting, dRibsLOWipe, dRibsLOWipeAng) end @@ -891,7 +896,7 @@ local function CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGr local nNextId = EgtGetNext( vNewEntIds[i]) or GDB_ID.NULL local nType = EgtGetInfo( nNextId, KEY_TYPE, 'i') if nType ~= TYPE.LINK then - AddRetraction( vNewEntIds[i], LayerParams, dCoastingLen, dWipeLen, dWipeDir) + AddRetraction( vNewEntIds[i], LayerParams.vtSlicing, LayerParams.dTDiam, dCoastingLen, dWipeLen, dWipeDir) end end end @@ -913,7 +918,7 @@ local function AddSpiralVaseLeadOut( nOldId, LayerParams) end AddRetractionOnLastCrv( nOldId, EgtGetParent( nOldId), LayerParams, LayerParams.dCoastingLen, LayerParams.dWipeLen, LayerParams.dWipeDir) else - AddRetraction( nOldId, LayerParams, LayerParams.dCoastingLen, LayerParams.dWipeLen, LayerParams.dWipeDir) + AddRetraction( nOldId, LayerParams.vtSlicing, LayerParams.dTDiam, LayerParams.dCoastingLen, LayerParams.dWipeLen, LayerParams.dWipeDir) end end @@ -1166,9 +1171,9 @@ function CalcToolPath.Exec( nPartId) if EgtGetInfo( nNextId, KEY_TYPE, 'i') ~= TYPE.LINK then -- aggiungo retrazione if nId == nFirstId then - AddRetraction( nId, LayerParams, dCoastingLen, EgtIf( LayerParams.nLeadInType == LEAD_TYPE.NONE, dWipeLen, 0), dWipeDir) + AddRetraction( nId, LayerParams.vtSlicing, LayerParams.dTDiam, dCoastingLen, EgtIf( LayerParams.nLeadInType == LEAD_TYPE.NONE, dWipeLen, 0), dWipeDir) else - AddRetraction( nId, LayerParams, dCoastingLen, dWipeLen, dWipeDir) + AddRetraction( nId, LayerParams.vtSlicing, LayerParams.dTDiam, dCoastingLen, dWipeLen, dWipeDir) end end end