3dPrinting :
- aggiunto collegamento infill.
This commit is contained in:
+257
-51
@@ -45,6 +45,7 @@ local function GetLayerParamsForToolPathCalc()
|
||||
LayerParams.dTDiam = EgtGetInfo( s_nPartId, KEY_TOOL_DIAM, 'd')
|
||||
-- parametri infill
|
||||
LayerParams.dInfillStrand = EgtGetInfo( s_nPartId, KEY_INFILL_STRAND, 'd') or LayerParams.dStrand
|
||||
LayerParams.bInfillLink = EgtGetInfo( s_nPartId, KEY_INFILL_LINK, 'b') or false
|
||||
LayerParams.dInfillCoasting = EgtGetInfo( s_nPartId, KEY_INFILL_COASTING, 'd') or 0
|
||||
LayerParams.dInfillWipe = EgtGetInfo( s_nPartId, KEY_INFILL_WIPE, 'd') or 0
|
||||
LayerParams.dInfillWipeDir = EgtGetInfo( s_nPartId, KEY_INFILL_WIPE_DIR, 'd') or 0
|
||||
@@ -611,7 +612,235 @@ local function CalcExtraShellToolPath( vEntIds, nTpathGrpId, LayerParams)
|
||||
end
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
----------------------- INFILL --------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
local function ComputeShortestCrv( nCrvId, dParS, dParE)
|
||||
|
||||
local nParentId = EgtGetParent( nCrvId)
|
||||
|
||||
-- verifico i due percorsi possibili dParS->dParE e dParE->dParS
|
||||
local nCopyId1 = EgtCopyGlob( nCrvId, nParentId, GDB_IN.AFTER)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvId, nParentId, 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( nCopyId1)
|
||||
return nCopyId2
|
||||
else
|
||||
EgtErase( nCopyId2)
|
||||
return nCopyId1
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
local function VerifyInfillLink( nLinkId, nCurr, nNext, vIds, dStrand, nGrpTmp)
|
||||
|
||||
-- regione occupata dal link
|
||||
local dOffs = dStrand * 0.5
|
||||
local nLinkSurf = EgtSurfFrFatCurve( nGrpTmp, nLinkId, dOffs, false)
|
||||
if not nLinkSurf then return true end
|
||||
|
||||
-- verifico non intersechi altre curve di infill
|
||||
for i = 1, #vIds do
|
||||
if vIds[i] ~= nCurr and vIds[i] ~= nNext then
|
||||
-- con curva
|
||||
local nRes = EgtCurveCurveInters( vIds[i], nLinkId, nGrpTmp)
|
||||
if nRes then return false end
|
||||
-- con regione occupata
|
||||
local nClassif = EgtCurveWithRegionClassify( vIds[i], nLinkSurf)
|
||||
if nClassif == GDB_CRC.INTERS or nClassif == GDB_CRC.IN then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- verifica con le curve coinvolte dal link
|
||||
if nLinkSurf then
|
||||
local nCurrCopy = EgtCopyGlob( nCurr, nGrpTmp)
|
||||
local _, nCnt = EgtTrimCurveWithRegion( nCurrCopy, nLinkSurf, true, false)
|
||||
if nCnt > 1 then return false end
|
||||
|
||||
local nNextCopy = EgtCopyGlob( nNext, nGrpTmp)
|
||||
_, nCnt = EgtTrimCurveWithRegion( nNextCopy, nLinkSurf, true, false)
|
||||
if nCnt > 1 then return false end
|
||||
|
||||
-- verifico se tratti lineari paralleli al setto sono sufficientemente lontani
|
||||
local nLinkLoc = EgtCopyGlob( nLinkId, nGrpTmp)
|
||||
local _, dParELink = EgtCurveDomain( nLinkLoc)
|
||||
local nCurrLoc = EgtCopyGlob( nCurr, nGrpTmp)
|
||||
local _, dParE = EgtCurveDomain( nCurrLoc)
|
||||
for dPar = dParE, max( 1, dParE - 3), -1 do
|
||||
local vtDirCurr = EgtUV( nCurrLoc, dPar - 0.5, -1)
|
||||
for dParCrv = 1, dParELink do
|
||||
local vtS = EgtUV( nLinkLoc, dParCrv - 1, 1)
|
||||
local vtE = EgtUV( nLinkLoc, dParCrv, -1)
|
||||
-- se tratto lineare allineato come curva corrente
|
||||
if AreSameVectorApprox( vtS, vtE) and vtS * vtDirCurr < - 1 + GEO.EPS_SMALL then
|
||||
-- verifico distanza
|
||||
local nCrvTest = EgtCurveCompoFromPoints( nGrpTmp, { EgtUP( nCurrLoc, dPar-1), EgtUP( nCurrLoc, dPar)})
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLinkLoc, dParCrv - 0.5), nCrvTest)
|
||||
if dDist < dStrand * 0.5 + GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local nNextLoc = EgtCopyGlob( nNext, nGrpTmp)
|
||||
_, dParE = EgtCurveDomain( nNextLoc)
|
||||
for dPar = 0, min( dParE - 1, 3) do
|
||||
local vtDirCurr = EgtUV( nNextLoc, dPar + 0.5, -1)
|
||||
for dParCrv = 1, dParELink do
|
||||
local vtS = EgtUV( nLinkLoc, dParCrv - 1, 1)
|
||||
local vtE = EgtUV( nLinkLoc, dParCrv, -1)
|
||||
-- se tratto lineare allineato come curva corrente
|
||||
if AreSameVectorApprox( vtS, vtE) and vtS * vtDirCurr < - 1 + GEO.EPS_SMALL then
|
||||
-- verifico distanza
|
||||
local nCrvTest = EgtCurveCompoFromPoints( nGrpTmp, { EgtUP( nCurrLoc, dPar), EgtUP( nCurrLoc, dPar + 1)})
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLinkLoc, dParCrv - 0.5), nNextLoc)
|
||||
if dDist < dStrand * 0.5 + GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CalcInfillLink( vIds, nInfillGrp, dStrand, LayerParams)
|
||||
|
||||
if #vIds == 0 then return end
|
||||
|
||||
-- estraggo i loop delle superfici usate per trim
|
||||
local nLoopGrp = EgtGroup( nInfillGrp)
|
||||
local tSurfs = {}
|
||||
for i = 1, #vIds do
|
||||
local nTrimSurf = EgtGetInfo( vIds[i], KEY_ASSOCIATED_SURF, 'i')
|
||||
-- controllo di non aver già estratto il suo loop
|
||||
if not tSurfs[nTrimSurf] then
|
||||
EgtMove( nTrimSurf, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
local nChunks = EgtSurfFrChunkCount( nTrimSurf)
|
||||
for i = 0, nChunks - 1 do
|
||||
EgtExtractSurfFrChunkLoops( nTrimSurf, i, nLoopGrp)
|
||||
end
|
||||
tSurfs[nTrimSurf] = 1
|
||||
end
|
||||
end
|
||||
local vCrvIds = EgtGetAllInGroup( nLoopGrp)
|
||||
|
||||
-- creo gruppo temporaneo per conti
|
||||
local frLoc = Frame3d( ORIG(), LayerParams.vtSlicing)
|
||||
local nGrpTmp = EgtGroup( nInfillGrp, frLoc, GDB_RT.GLOB)
|
||||
|
||||
-- creo vettore corrispondente a vIds per indicare quando la curva viene utilizzata nei link
|
||||
local vUsed = {}
|
||||
for i = 1, #vIds do
|
||||
vUsed[i] = false
|
||||
end
|
||||
|
||||
-- scorro le curve per creare link
|
||||
local nCurr = vIds[1]
|
||||
vUsed[1] = true
|
||||
while nCurr do
|
||||
local bFound = false
|
||||
-- cerco tra le curve non utilizzate quale può essere usata per link
|
||||
for i = 1, #vIds do
|
||||
if bFound then break end
|
||||
if not vUsed[i] then
|
||||
local nNext = vIds[i]
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
if not AreSamePointApprox( ptS, ptE) then
|
||||
-- cerco di creare il link
|
||||
for k = 1, #vCrvIds do
|
||||
local dParS = EgtCurveParamAtPoint( vCrvIds[k], ptS, 10 * GEO.EPS_SMALL)
|
||||
local dParE = EgtCurveParamAtPoint( vCrvIds[k], ptE, 10 * GEO.EPS_SMALL)
|
||||
if dParS and dParE then
|
||||
local nLinkId = ComputeShortestCrv( vCrvIds[k], dParS, dParE)
|
||||
if nLinkId then
|
||||
local bValid = VerifyInfillLink( nLinkId, nCurr, nNext, vIds, dStrand, nGrpTmp)
|
||||
if not bValid then
|
||||
EgtErase( nLinkId)
|
||||
else
|
||||
bFound = true
|
||||
-- riposiziono le curve collegate
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.AFTER)
|
||||
EgtRelocateGlob( nNext, nLinkId, GDB_IN.AFTER)
|
||||
-- sistemo le info del link
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.INFILL)
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLinkId, KEY_CRV_STRAND, dStrand)
|
||||
|
||||
-- aggiorno per iterazione successiva
|
||||
nCurr = vIds[i]
|
||||
vUsed[i] = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- se link non è stato realizzato cerco il primo tratto non utilizzato da cui ripartire
|
||||
if not bFound then
|
||||
for i = 1, #vIds do
|
||||
if not vUsed[i] then
|
||||
nCurr = vIds[i]
|
||||
vUsed[i] = true
|
||||
bFound = true
|
||||
break
|
||||
end
|
||||
end
|
||||
-- se tutti i tratti utilizzati ho finito
|
||||
if not bFound then nCurr = nil end
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nGrpTmp)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CalcInfillToolPath( nInfillGrp, nTpathGrpId, LayerParams)
|
||||
|
||||
local vEntIds = EgtGetNameInGroup( nInfillGrp, INFILL_CRV ..'*')
|
||||
if not vEntIds or #vEntIds == 0 then return end
|
||||
|
||||
-- aggiungo le curve nel toolpath
|
||||
local vIds = AddCurvesToToolPath( vEntIds, nTpathGrpId, PRINT_ORDER.EXT_INT, false, LayerParams.vtSlicing, LayerParams.dLayHeight)
|
||||
|
||||
-- assegno strand
|
||||
for i = 1, #vIds do
|
||||
EgtSetInfo( vIds[i], KEY_CRV_STRAND, LayerParams.dInfillStrand)
|
||||
end
|
||||
|
||||
-- eventuale creazione dei link
|
||||
if LayerParams.bInfillLink then
|
||||
CalcInfillLink( vIds, nInfillGrp, LayerParams.dInfillStrand, LayerParams)
|
||||
end
|
||||
|
||||
-- aggiungo coasting e wipe
|
||||
for i = 1, #vIds do
|
||||
local nNext = EgtGetNext( vIds[i])
|
||||
if not nNext or EgtGetName( nNext) ~= LINK_CRV then
|
||||
AddRetraction( vIds[i], LayerParams.vtSlicing, LayerParams.dInfillCoasting, LayerParams.dInfillWipe, LayerParams.dInfillWipeDir)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
----------------------- SOLID FILL ----------------------------------
|
||||
---------------------------------------------------------------------
|
||||
local function CalcSolidFillToolPath( nInfillGrp, nTpathGrpId, LayerParams)
|
||||
|
||||
local vEntIds = EgtGetNameInGroup( nInfillGrp, INFILL_CRV ..'*')
|
||||
@@ -652,26 +881,6 @@ local function CalcSolidFillToolPath( nInfillGrp, nTpathGrpId, LayerParams)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function CalcInfillToolPath( nInfillGrp, nTpathGrpId, LayerParams)
|
||||
|
||||
local vEntIds = EgtGetNameInGroup( nInfillGrp, INFILL_CRV ..'*')
|
||||
if not vEntIds or #vEntIds == 0 then return end
|
||||
|
||||
-- aggiungo le curve nel toolpath
|
||||
local vIds = AddCurvesToToolPath( vEntIds, nTpathGrpId, PRINT_ORDER.EXT_INT, false, LayerParams.vtSlicing, LayerParams.dLayHeight)
|
||||
|
||||
-- assegno strand
|
||||
for i = 1, #vIds do
|
||||
EgtSetInfo( vIds[i], KEY_CRV_STRAND, LayerParams.dInfillStrand)
|
||||
end
|
||||
|
||||
-- aggiungo coasting e wipe
|
||||
for i = 1, #vIds do
|
||||
AddRetraction( vIds[i], LayerParams.vtSlicing, LayerParams.dInfillCoasting, LayerParams.dInfillWipe, LayerParams.dInfillWipeDir)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------
|
||||
local function JoinShellsAndSolidFills( nInfillGrp, vShellIds, vExtraShells, LayerParams, tabRibs)
|
||||
|
||||
@@ -721,7 +930,9 @@ local function JoinShellsAndSolidFills( nInfillGrp, vShellIds, vExtraShells, Lay
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-------------------------------------------------------------------
|
||||
----------------------- AUX SOLIDS -------------------------------
|
||||
-------------------------------------------------------------------
|
||||
local function CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGrpId, LayerParams)
|
||||
|
||||
if not nAuxSolidsGrp or not nAuxSolidsPathGrp then return end
|
||||
@@ -732,7 +943,7 @@ local function CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGr
|
||||
|
||||
-- recupero tutti i percorsi relativi a quel solido
|
||||
local sName = EgtGetName( nSolidId)
|
||||
local vEntIds = EgtGetNameInGroup( nAuxSolidsPathGrp, sName .. '*')
|
||||
local vEntIds = EgtGetNameInGroup( nAuxSolidsPathGrp, sName .. '*')
|
||||
if vEntIds then
|
||||
|
||||
-- recupero i parametri relativi al solido dalla curva di slicing
|
||||
@@ -752,21 +963,39 @@ local function CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGr
|
||||
end
|
||||
|
||||
-- aggiungo link e offset lead point
|
||||
local vShells = {}
|
||||
local vInfill = {}
|
||||
for i = 1, #vIds do
|
||||
local nType = EgtGetInfo( vIds[i], KEY_TYPE, 'i')
|
||||
local bZigZag = EgtGetInfo( vIds[i], KEY_ZIG_ZAG_INFILL, 'b') or false
|
||||
if nType == TYPE.INFILL or bZigZag then
|
||||
table.insert( vInfill, vIds[i])
|
||||
else
|
||||
table.insert( vShells, vIds[i])
|
||||
end
|
||||
end
|
||||
|
||||
if nFillType == FILL_TYPE.OFFSET or nFillType == FILL_TYPE.NONE then
|
||||
local nLinkType = EgtGetInfo( nSolidId, KEY_AUX_SOLIDS_LINK_TYPE, 'i')
|
||||
local dLinkParam = EgtGetInfo( nSolidId, KEY_AUX_SOLIDS_LINK_PARAM, 'd')
|
||||
local dSPOffset = EgtGetInfo( nSolidId, KEY_AUX_SOLIDS_SP_OFFSET, 'd')
|
||||
local dLPOffset = EgtGetInfo( nSolidId, KEY_AUX_SOLIDS_LP_OFFSET, 'd')
|
||||
|
||||
local nFirstCopy = EgtCopyGlob( vIds[1], nTpathGrpId) -- necessaria per avere il corretto offset lead point sulla shell esterna nel caso di link
|
||||
AddLink( vIds, nTpathGrpId, nLinkType, dLinkParam, dSPOffset, nOrder, LayerParams.vtSlicing)
|
||||
AddOffsetLeadPoint( vIds, nFirstCopy, dLPOffset, nLinkType)
|
||||
local nFirstCopy = EgtCopyGlob( vShells[1], nTpathGrpId) -- necessaria per avere il corretto offset lead point sulla shell esterna nel caso di link
|
||||
AddLink( vShells, nTpathGrpId, nLinkType, dLinkParam, dSPOffset, nOrder, LayerParams.vtSlicing)
|
||||
AddOffsetLeadPoint( vShells, nFirstCopy, dLPOffset, nLinkType)
|
||||
|
||||
elseif nFillType & FILL_CATEGORY.INFILL ~= 0 then
|
||||
local bInfillLink = EgtGetInfo( nSolidId, KEY_AUX_SOLIDS_INFILL, 'b')
|
||||
if bInfillLink then
|
||||
CalcInfillLink( vInfill, nAuxSolidsPathGrp, dStrand, LayerParams)
|
||||
end
|
||||
end
|
||||
|
||||
-- coasting e wipe
|
||||
for i = 1, #vIds do
|
||||
local nNextId = EgtGetNext( vIds[i])
|
||||
if not nNextId or EgtGetInfo( nNextId, KEY_TYPE, 'i') ~= TYPE.LINK then
|
||||
if not nNextId or EgtGetName( nNextId) ~= LINK_CRV then
|
||||
AddRetraction( vIds[i], LayerParams.vtSlicing, dCoastingLen, dWipeLen, dWipeDir)
|
||||
end
|
||||
end
|
||||
@@ -778,7 +1007,7 @@ local function CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGr
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
--------------------------------------------------------------------
|
||||
--------------------------- RIBS -----------------------------------
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
@@ -883,29 +1112,6 @@ local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeShortestCrv( nCrvId, dParS, dParE)
|
||||
|
||||
local nParentId = EgtGetParent( nCrvId)
|
||||
|
||||
-- verifico i due percorsi possibili dParS->dParE e dParE->dParS
|
||||
local nCopyId1 = EgtCopyGlob( nCrvId, nParentId, GDB_IN.AFTER)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvId, nParentId, 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( nCopyId1)
|
||||
return nCopyId2
|
||||
else
|
||||
EgtErase( nCopyId2)
|
||||
return nCopyId1
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeRibsLinkOnDiffCrvs( nCrvS, nCrvE, dParS, dParE)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user