3dPrinting :

- corretta approssimazione toolpath in spiral vase.
This commit is contained in:
SaraP
2024-01-31 10:11:08 +01:00
parent e4c696c498
commit 17f295ebf4
+61 -50
View File
@@ -1926,66 +1926,77 @@ local function SpiralVase( vLayIds, LayerParams)
return false
end
local nNewEntId = EgtCopyGlob( vEntIds[1], nTpathGrpId, GDB_IN.LAST_SON)
local nNewEntId = EgtCopyGlob( vEntIds[1] or GDB_ID.NULL, nTpathGrpId, GDB_IN.LAST_SON)
if nNewEntId then
local vtMove = V_NULL()
-- eventuale spostamento dell'altezza layer
if nSlicingType == SLICING_TYPE.DEG45_X or nSlicingType == SLICING_TYPE.DEG45_Y then
vtMove = LayerParams.dLayHeight * LayerParams.vtSlicing
EgtMove( nNewEntId, vtMove, GDB_RT.GLOB)
end
EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB)
EgtSetInfo( nNewEntId, KEY_CRV_STRAND, LayerParams.dStrand)
-- eventuale inversione
if LayerParams.bInvert then
EgtInvertCurve( nNewEntId)
EgtSetInfo( nNewEntId, KEY_INVERTED_CRV, 1)
end
EgtSetColor( nNewEntId, EgtStdColor('GRAY'))
-- se primo layer
if bFirst and nNewEntId then
-- 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( nNewEntId, LayerParams.dOffsetLP)
AddLeadIn( nNewEntId, LayerParams, nTpathGrpId)
local vtMove = V_NULL()
-- eventuale spostamento dell'altezza layer
if nSlicingType == SLICING_TYPE.DEG45_X or nSlicingType == SLICING_TYPE.DEG45_Y then
vtMove = LayerParams.dLayHeight * LayerParams.vtSlicing
EgtMove( nNewEntId, vtMove, GDB_RT.GLOB)
end
bFirst = false
else
local ptOld = EgtEP( nOldId, GDB_ID.ROOT)
local ptNew = EgtSP( nNewEntId, GDB_ID.ROOT)
if dist( ptNew, ptOld) < LayerParams.dStrand then
-- se i punti sono vicini ma non coincidenti modifico la curva per avere transizione più uniforme
if not AreSamePointApprox( ptOld, ptNew) then
-- recupero la curva da usare come guida
local nGuideId = EgtCopyGlob( nOldPathId, nTpathGrpId)
-- la porto alla stessa quota del toolpath
EgtMove( nGuideId, vtMove + LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB)
EgtChangeClosedCurveStartPoint( nGuideId, ptOld, GDB_RT.GLOB)
EgtSpiralizeCurveAlongGuide( nNewEntId, nGuideId)
EgtErase( nGuideId)
EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB)
EgtSetInfo( nNewEntId, KEY_CRV_STRAND, LayerParams.dStrand)
-- eventuale inversione
if LayerParams.bInvert then
EgtInvertCurve( nNewEntId)
EgtSetInfo( nNewEntId, KEY_INVERTED_CRV, 1)
end
EgtSetColor( nNewEntId, EgtStdColor('GRAY'))
-- se primo layer
if bFirst then
-- 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( nNewEntId, LayerParams.dOffsetLP)
AddLeadIn( nNewEntId, LayerParams, nTpathGrpId)
end
bFirst = false
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)
local ptOld = EgtEP( nOldId, GDB_ID.ROOT)
local ptNew = EgtSP( nNewEntId, GDB_ID.ROOT)
if dist( ptNew, ptOld) < LayerParams.dStrand then
-- se i punti sono vicini ma non coincidenti modifico la curva per avere transizione più uniforme
if not AreSamePointApprox( ptOld, ptNew) then
-- recupero la curva da usare come guida
local nGuideId = EgtCopyGlob( nOldPathId, nTpathGrpId)
-- la porto alla stessa quota del toolpath
EgtMove( nGuideId, vtMove + LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB)
EgtChangeClosedCurveStartPoint( nGuideId, ptOld, GDB_RT.GLOB)
EgtSpiralizeCurveAlongGuide( nNewEntId, nGuideId)
EgtErase( nGuideId)
end
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
EgtSpiralizeCurveAlongExtrusion( nNewEntId, LayerParams.dLayHeight)
end
EgtSpiralizeCurveAlongExtrusion( nNewEntId, LayerParams.dLayHeight)
EgtApproxCurve( nNewEntId, GDB_CA.ARCS, s_dApproxTol)
-- approssimo la curva
if nNewEntId then
local ptS = EgtSP( nNewEntId, GDB_ID.ROOT)
EgtApproxCurve( nNewEntId, GDB_CA.ARCS, s_dApproxTol)
if EgtCurveIsClosed( nNewEntId) then
EgtChangeClosedCurveStartPoint( nNewEntId, ptS, GDB_RT.GLOB)
end
end
nOldPathId = vEntIds[1]
nOldId = nNewEntId
end
nOldPathId = vEntIds[1]
nOldId = nNewEntId
-- aggiorno il box dei toolpath
local b3Box = ComputeToolPathBox( nTpathGrpId)
b3Tot:Add( b3Box)
end
if EgtProcessEvents( EgtIf( PRINT, 300, 0) + nIdx / #vLayIds * 100, 0) == 1 then