diff --git a/LuaLibs/CalcToolPath.lua b/LuaLibs/CalcToolPath.lua index c40caa3..294bdee 100644 --- a/LuaLibs/CalcToolPath.lua +++ b/LuaLibs/CalcToolPath.lua @@ -955,6 +955,17 @@ local function SpiralVase( vLayIds, dCorrZ, LayerParams) local nOldId local bFirst = true + local nSlicingType = EgtGetInfo( s_nPartId, KEY_SLICING_TYPE, 'i') + + -- copio ultimo layer + if nSlicingType ~= SLICING_TYPE.DEG45 then + local nNewLay = EgtCopyGlob( vLayIds[#vLayIds], vLayIds[#vLayIds], GDB_IN.AFTER) + table.insert( vLayIds, nNewLay) + local sOldIdx = string.sub( EgtGetName( vLayIds[#vLayIds]), 6) + local nNewIdx = tonumber( sOldIdx) + 1 + EgtSetName( nNewLay, SLICE_LAYER .. EgtNumToString( nNewIdx)) + EgtMove( nNewLay, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) + end -- ciclo sui layer for nIdx = 1, #vLayIds do @@ -986,16 +997,16 @@ local function SpiralVase( vLayIds, dCorrZ, LayerParams) end -- creo il percorso di lavoro : - -- copio le curve, le ordino, le oriento e le muovo in Z local nEntId = EgtGetFirstInGroup( nPathGrpId) while nEntId do local nNewEntId = EgtCopyGlob( nEntId, nTpathGrpId, GDB_IN.LAST_SON) - + -- correggo posizione in Z ( per essere sicuri di appoggiare sul piano) EgtMove( nNewEntId, dCorrZ * Z_AX(), GDB_RT.GLOB) - -- mi sposto dell'altezza layer - EgtMove( nNewEntId, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) - + if nSlicingType == SLICING_TYPE.DEG45 then + -- eventuale spostamento dell'altezza layer + EgtMove( nNewEntId, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) + end EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB) -- eventuale inversione if LayerParams.bInvert then @@ -1004,32 +1015,31 @@ local function SpiralVase( vLayIds, dCorrZ, LayerParams) end EgtSetColor( nNewEntId, EgtStdColor('GRAY')) - -- se primo layer devo farne copia + -- se primo layer if bFirst and nNewEntId then - local nFirstCrv = EgtCopyGlob( nNewEntId, nTpathGrpId, GDB_IN.FIRST_SON) - EgtModifyCurveExtrusion( nFirstCrv, LayerParams.vtSlicing, GDB_RT.GLOB) + -- mi sposto dell'altezza layer + EgtMove( nNewEntId, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) -- eventuale lead in if LayerParams.nLeadInType ~= LEAD_TYPE.NONE then - EgtTrimCurveStartAtLen( nFirstCrv, LayerParams.dOffsetLP) - AddLeadIn( nFirstCrv, LayerParams, nTpathGrpId) + EgtTrimCurveStartAtLen( nNewEntId, LayerParams.dOffsetLP) + AddLeadIn( nNewEntId, LayerParams, nTpathGrpId) end - nOldId = nNewEntId bFirst = false - end - - -- modifico lo start point per collegarlo alla curva precedente - local ptOld = EgtEP( nOldId) - if dist( EgtSP( nNewEntId), ptOld) < LayerParams.dStrand + 10 then - EgtChangeClosedCurveStartPoint( nNewEntId, ptOld) - EgtModifyCurveStartPoint( nNewEntId, ptOld) else - EgtOutLog( 'Warning : in spiral vase mode no link betweeen toolpaths (layer '..tostring( nIdx)..') - CalcToolPath') - -- aggiungo uscita, coasting e wipe sulla curva precedente - AddSpiralVaseLeadOut( nOldId, LayerParams) + -- modifico lo start point per collegarlo alla curva precedente + local ptOld = EgtEP( nOldId, GDB_ID.ROOT) + if dist( EgtSP( nNewEntId, GDB_ID.ROOT), ptOld) < LayerParams.dStrand + 10 then + EgtChangeClosedCurveStartPoint( nNewEntId, ptOld, GDB_RT.GLOB) + EgtModifyCurveStartPoint( nNewEntId, ptOld, GDB_RT.GLOB) + else + EgtOutLog( 'Warning : in spiral vase mode no link betweeen toolpaths (layer '..tostring( nIdx)..') - CalcToolPath') + -- aggiungo uscita, coasting e wipe sulla curva precedente + AddSpiralVaseLeadOut( nOldId, LayerParams) + end + EgtSpiralizeCurve( nNewEntId, LayerParams.dLayHeight) end nOldId = nNewEntId - EgtSpiralizeCurve( nNewEntId, LayerParams.dLayHeight) nEntId = EgtGetNext( nEntId) end end @@ -1042,7 +1052,7 @@ local function SpiralVase( vLayIds, dCorrZ, LayerParams) -- aggiungo uscita, coasting e wipe su ultima curva AddSpiralVaseLeadOut( nOldId, LayerParams) - + end ---------------------------------------------------------------------