3dPrinting :
- aggiunti setti.
This commit is contained in:
+212
-7
@@ -35,7 +35,18 @@ local function GetLayerParamsForToolPathCalc()
|
||||
LayerParams.dWipeLen = EgtGetInfo( nParamsGrp, KEY_WIPE_LEN, 'd')
|
||||
LayerParams.vtSlicing = EgtGetInfo( nParamsGrp, KEY_SLICING_DIR, 'v')
|
||||
LayerParams.dTDiam = EgtGetInfo( nParamsGrp, KEY_TOOL_DIAM, 'd')
|
||||
|
||||
-- Parametri setti
|
||||
LayerParams.nSettiShellsNbr = EgtGetInfo( nParamsGrp, KEY_SETTI_SHELLS_NBR, 'i')
|
||||
LayerParams.bSettiLink = EgtGetInfo( nParamsGrp, KEY_SETTI_LINK, 'b')
|
||||
LayerParams.bSettiInvert = EgtGetInfo( nParamsGrp, KEY_SETTI_INVERT, 'b')
|
||||
LayerParams.bSettiLIInvert = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_IN_INVERT, 'b')
|
||||
LayerParams.dSettiLILen = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_IN_LEN, 'd')
|
||||
LayerParams.bSettiLOInvert = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_OUT_INVERT, 'b')
|
||||
LayerParams.dSettiLOLen = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_OUT_LEN, 'd')
|
||||
LayerParams.dSettiLOWipeTang = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_OUT_WIPE1, 'd')
|
||||
LayerParams.dSettiLOWipe = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_OUT_WIPE2, 'd')
|
||||
LayerParams.dSettiLOWipeAng = EgtGetInfo( nParamsGrp, KEY_SETTI_LEAD_OUT_WIPE_DIR, 'd')
|
||||
|
||||
return LayerParams
|
||||
end
|
||||
|
||||
@@ -158,6 +169,194 @@ local function AddRetractionOnLastCrv( nTpathGrpId, LayerParams)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcSettiLink( nSettiGrp, nLoopGrp, LayerParams, nTpathGrpId)
|
||||
|
||||
local nCrvId = EgtGetFirstInGroup( nLoopGrp)
|
||||
local nCurr = EgtGetFirstNameInGroup( nTpathGrpId, SETTI_CRV .. '*')
|
||||
while nCurr do
|
||||
local nNext = EgtGetNextName( nCurr, SETTI_CRV .. '*')
|
||||
if nNext then
|
||||
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
local dParS = EgtCurveParamAtPoint( nCrvId, ptS)
|
||||
local dParE = EgtCurveParamAtPoint( nCrvId, ptE)
|
||||
|
||||
if dParE then
|
||||
-- verifico i due percorsi ( dParS->dParE e dParE->dParS)
|
||||
local nCopyId1 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId1, dParS, dParE)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId2, dParE, dParS)
|
||||
EgtInvertCurve( nCopyId2)
|
||||
|
||||
local dLen1 = EgtCurveLength( nCopyId1)
|
||||
local dLen2 = EgtCurveLength( nCopyId2)
|
||||
if dLen1 < dLen2 then
|
||||
EgtErase( nCopyId2)
|
||||
EgtSetInfo( nCopyId1, KEY_TYPE, TYPE.SETTO)
|
||||
else
|
||||
EgtErase( nCopyId1)
|
||||
EgtSetInfo( nCopyId2, KEY_TYPE, TYPE.SETTO)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- passo alla successiva
|
||||
nCurr = nNext
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddSettiLeadIn( nCrv, nLoopsGrp, dLeadInLen, bInvert)
|
||||
|
||||
if dLeadInLen < GEO.EPS_SMALL then return end
|
||||
|
||||
-- recupero la curva di offset
|
||||
local nCrvOffs = EgtGetFirstInGroup( nLoopsGrp)
|
||||
local nCopyOffs = EgtCopyGlob( nCrvOffs, nCrv, GDB_IN.BEFORE)
|
||||
|
||||
local ptS = EgtSP( nCrv)
|
||||
EgtChangeClosedCurveStartPoint( nCopyOffs, ptS)
|
||||
if bInvert then
|
||||
EgtInvertCurve( nCopyOffs)
|
||||
end
|
||||
EgtTrimCurveEndAtLen( nCopyOffs, dLeadInLen)
|
||||
EgtInvertCurve( nCopyOffs)
|
||||
EgtSetInfo( nCopyOffs, KEY_TYPE, TYPE.SETTO)
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddSettiLeadOut( nCrv, nTPathGrp, nLoopsGrp, LayerParams, bInvert)
|
||||
|
||||
-- recupero la curva di offset
|
||||
local nCrvOffs = EgtGetFirstInGroup( nLoopsGrp)
|
||||
local ptE = EgtEP( nCrv)
|
||||
local vtE = EgtUV( nCrvOffs, EgtCurveParamAtPoint( nCrvOffs, ptE), 1)
|
||||
if bInvert then vtE = - vtE end
|
||||
local nCrvLO
|
||||
local nWipe
|
||||
|
||||
-- primo tratto ( segue offset con flusso aperto)
|
||||
if LayerParams.dSettiLOLen > GEO.EPS_SMALL then
|
||||
nCrvLO = EgtCopyGlob( nCrvOffs, nCrv, GDB_IN.AFTER)
|
||||
EgtChangeClosedCurveStartPoint( nCrvLO, ptE)
|
||||
if bInvert then
|
||||
EgtInvertCurve( nCrvLO)
|
||||
end
|
||||
EgtTrimCurveEndAtLen( nCrvLO, LayerParams.dSettiLOLen)
|
||||
EgtSetInfo( nCrvLO, KEY_TYPE, TYPE.SETTO)
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nCrvLO)
|
||||
vtE = EgtEV( nCrvLO)
|
||||
end
|
||||
|
||||
-- secondo tratto ( segue offset con flusso chiuso)
|
||||
if LayerParams.dSettiLOWipeTang > GEO.EPS_SMALL then
|
||||
nWipe = EgtCopyGlob( nCrvOffs, nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
EgtChangeClosedCurveStartPoint( nWipe, ptE)
|
||||
if bInvert then
|
||||
EgtInvertCurve( nWipe)
|
||||
end
|
||||
EgtTrimCurveEndAtLen( nWipe, LayerParams.dSettiLOWipeTang)
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nWipe)
|
||||
vtE = EgtEV( nWipe)
|
||||
end
|
||||
|
||||
-- terzo tratto ( diretto verso esterno con ugello chiuso)
|
||||
if LayerParams.dSettiLOWipe > GEO.EPS_SMALL then
|
||||
local dAng = EgtIf( bInvert, 90, - 90) + LayerParams.dSettiLOWipeAng
|
||||
vtE:rotate( LayerParams.vtSlicing, dAng)
|
||||
local ptFinal = ptE + vtE * LayerParams.dSettiLOWipe
|
||||
if nWipe then
|
||||
-- unisco al secondo tratto così da averne uno solo per il wiping
|
||||
EgtAddCurveCompoLine( nWipe, ptFinal)
|
||||
else
|
||||
nWipe = EgtCurveCompoFromPoints( nTPathGrp, { ptE, ptFinal})
|
||||
EgtRelocateGlob( nWipe, nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
end
|
||||
end
|
||||
|
||||
if nWipe then
|
||||
EgtSetName( nWipe, WIPE_CRV)
|
||||
EgtSetInfo( nWipe, KEY_TYPE, TYPE.WIPE)
|
||||
EgtSetColor( nWipe, EgtStdColor('TEAL'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CalcSettiToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
|
||||
local nSettiGrp = EgtGetFirstNameInGroup( nCrvGrp, SETTI_GRP)
|
||||
-- aggiungo i setti nel toolpath
|
||||
local vEntIds = EgtGetNameInGroup( nSettiGrp, SETTI_CRV .. '*')
|
||||
for i = 1, #vEntIds do
|
||||
-- copio entità nel gruppo toolpath
|
||||
local nNewEntId = EgtCopyGlob( vEntIds[i], 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)
|
||||
EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetColor( nNewEntId, EgtStdColor('GRAY'))
|
||||
|
||||
-- eventuale inversione delle curva
|
||||
if LayerParams.bSettiLink then
|
||||
-- se link le curve devono avere direzioni alternate
|
||||
if ( LayerParams.bSettiInvert and i % 2 == 1) or
|
||||
( not LayerParams.bSettiInvert and i % 2 == 0) then
|
||||
EgtInvertCurve( nNewEntId)
|
||||
end
|
||||
else
|
||||
if LayerParams.bSettiInvert then
|
||||
EgtInvertCurve( nNewEntId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- estraggo i contorni delle superfici di offset
|
||||
local nLoopGrp = EgtGroup( nSettiGrp)
|
||||
local nSrfId = EgtGetFirstNameInGroup( nSettiGrp, LAYER_SRF)
|
||||
local nChunksNbr = EgtSurfFrChunkCount( nSrfId)
|
||||
for i = 0, nChunksNbr do
|
||||
local nRes, nCnt = EgtExtractSurfFrChunkLoops( nSrfId, i, nLoopGrp)
|
||||
if nRes then
|
||||
for j = nRes, nRes + nCnt - 1 do
|
||||
EgtMove( j, dCorrZ * Z_AX(), GDB_RT.GLOB)
|
||||
-- mi sposto dell'altezza layer
|
||||
EgtMove( j, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- collegamenti e leadin/leadout
|
||||
if LayerParams.bSettiLink then
|
||||
-- collego i setti
|
||||
CalcSettiLink( nSettiGrp, nLoopGrp, LayerParams, nTpathGrpId)
|
||||
-- aggiungo ingresso e uscita solo sul primo e sull'ultimo setto
|
||||
local nFirst = EgtGetFirstNameInGroup( nTpathGrpId, SETTI_CRV .. '*')
|
||||
local bInvertLI = EgtIf( LayerParams.nSettiShellsNbr == 1, LayerParams.bSettiLIInvert, not LayerParams.bSettiInvert)
|
||||
if nFirst then AddSettiLeadIn( nFirst, nLoopGrp, LayerParams.dSettiLILen, bInvertLI) end
|
||||
local nLast = EgtGetLastNameInGroup( nTpathGrpId, SETTI_CRV .. '*')
|
||||
local bInvertLO = LayerParams.bSettiLOInvert
|
||||
if LayerParams.nSettiShellsNbr > 1 then
|
||||
bInvertLO = EgtIf( #vEntIds % 2 == 0, not bInvertLI, bInvertLI)
|
||||
end
|
||||
if nLast then AddSettiLeadOut( nLast, nTpathGrpId, nLoopGrp, LayerParams, bInvertLO) end
|
||||
|
||||
elseif LayerParams.nSettiShellsNbr == 1 then
|
||||
local vNewEntIds = EgtGetNameInGroup( nTpathGrpId, SETTI_CRV .. '*')
|
||||
for i = 1, #vNewEntIds do
|
||||
AddSettiLeadIn( vNewEntIds[i], nLoopGrp, LayerParams.dSettiLILen, LayerParams.bSettiLIInvert)
|
||||
AddSettiLeadOut( vNewEntIds[i], nTpathGrpId, nLoopGrp, LayerParams, LayerParams.bSettiLOInvert)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function CalcToolPath.Exec( nPartId)
|
||||
|
||||
@@ -176,7 +375,8 @@ function CalcToolPath.Exec( nPartId)
|
||||
|
||||
-- recupero i parametri per calcolo dei toolpath
|
||||
local LayerParams = GetLayerParamsForToolPathCalc()
|
||||
|
||||
local dCorrZ = ComputeZCorrection( LayerParams)
|
||||
|
||||
-- Ciclo sui layer
|
||||
for nIdx = 1, #vLayIds do
|
||||
|
||||
@@ -204,14 +404,13 @@ function CalcToolPath.Exec( nPartId)
|
||||
local nEntId = EgtGetFirstInGroup( nPathGrpId)
|
||||
while nEntId do
|
||||
local nNewEntId = EgtCopyGlob( nEntId, nTpathGrpId, EgtIf( LayerParams.nOrder == PRINT_ORDER.INF_INT_EXT, GDB_IN.FIRST_SON, GDB_IN.LAST_SON))
|
||||
-- correggo posizione in Z ( per essere sicuri di appoggiare sul piano)
|
||||
local dCorr = ComputeZCorrection( LayerParams)
|
||||
EgtMove( nNewEntId, dCorr * Z_AX(), GDB_RT.GLOB)
|
||||
-- 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 LayerParams.bInvert then
|
||||
EgtInvertCurve( nNewEntId)
|
||||
end
|
||||
end
|
||||
EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetColor( nNewEntId, EgtStdColor('GRAY'))
|
||||
nEntId = EgtGetNext( nEntId)
|
||||
@@ -309,10 +508,16 @@ function CalcToolPath.Exec( nPartId)
|
||||
nId = EgtGetNextName( nId, SHELL_CRV .. "*")
|
||||
end
|
||||
|
||||
-- sistemo i setti
|
||||
local nSettiGrp = EgtGetFirstNameInGroup( nCrvGrpId, SETTI_GRP)
|
||||
if nSettiGrp then
|
||||
CalcSettiToolPath( nCrvGrpId, nTpathGrpId, LayerParams, dCorrZ)
|
||||
end
|
||||
|
||||
--passo al gruppo di contorni successivo
|
||||
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user