3dPrinting :
- correzioni nelle intersezioni costolature.
This commit is contained in:
+61
-16
@@ -178,8 +178,27 @@ local function AddRetractionOnLastCrv( nTpathGrpId, LayerParams)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcRibsLink( ptS, ptE, nCurr, nLoopGrp, bForceLink)
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext)
|
||||
|
||||
-- verifico se il link interseca una delle altre costolature
|
||||
local nGrp = EgtGetParent( nCurr)
|
||||
local vRibsIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. '*')
|
||||
for i = 1, #vRibsIds do
|
||||
if vRibsIds[i] ~= nCurr and vRibsIds[i] ~= nNext then
|
||||
local ptInt = EgtIP( nLinkId, vRibsIds[i], ORIG())
|
||||
if ptInt then return false end
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink)
|
||||
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
|
||||
local nCrvId = EgtGetFirstInGroup( nLoopGrp)
|
||||
-- recupero la curva di offset su cui calcolare link
|
||||
while nCrvId do
|
||||
@@ -217,6 +236,13 @@ local function CalcRibsLink( ptS, ptE, nCurr, nLoopGrp, bForceLink)
|
||||
EgtTrimCurveStartEndAtParam( nLinkId, dParS, dParE)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
if bInvert then EgtInvertCurve( nLinkId) end
|
||||
-- verifico se è valido
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext)
|
||||
if not bValid then
|
||||
EgtErase( nLinkId)
|
||||
EgtErase( nCopyId)
|
||||
return
|
||||
end
|
||||
|
||||
if bClosed then
|
||||
EgtTrimCurveStartEndAtParam( nCrvId, dParE, dParS)
|
||||
@@ -225,8 +251,8 @@ local function CalcRibsLink( ptS, ptE, nCurr, nLoopGrp, bForceLink)
|
||||
EgtTrimCurveEndAtParam( nCrvId, dParS)
|
||||
EgtTrimCurveStartAtParam( nCopyId, dParE)
|
||||
end
|
||||
|
||||
return nLinkId
|
||||
|
||||
return nLinkId
|
||||
end
|
||||
|
||||
nCrvId = EgtGetNext( nCrvId)
|
||||
@@ -446,38 +472,59 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
|
||||
local bInters = EgtGetInfo( nRibsGrp, KEY_RIBS_INTERS, 'b') or false
|
||||
local bSpecialCase = bInters and LayerParams.nRibsShellsNbr == 2
|
||||
local bSwap = false
|
||||
-- orientamento delle curve
|
||||
local bInvert = LayerParams.bRibsInvert
|
||||
local bInvert = LayerParams.bRibsInvert
|
||||
if not bSpecialCase then
|
||||
for i = 1, #tabRibs do
|
||||
local nInfo = EgtGetInfo( tabRibs[i][1], KEY_SPLIT_RIB, 'i')
|
||||
-- aggiorno bInvert per il gruppo di costolature analizzato
|
||||
if i > 1 and not nInfo then
|
||||
if LayerParams.bRibsLink and LayerParams.nRibsShellsNbr % 2 == 1 then
|
||||
bInvert = not bInvert
|
||||
end
|
||||
end
|
||||
|
||||
if LayerParams.nRibsShellsNbr == 1 and nInfo and bInvert then
|
||||
-- se inverto direzione di costolature divise allora devo invertirne anche l'ordine di realizzazione
|
||||
bSwap = true
|
||||
EgtRelocateGlob( tabRibs[i][1], tabRibs[i-1][1], GDB_IN.BEFORE)
|
||||
end
|
||||
|
||||
-- oriento tutte le passate relative ad una stessa costolatura
|
||||
for j = 1, #tabRibs[i] do
|
||||
if ( bInvert and j % 2 == 1) or ( not bInvert and j % 2 == 0) then
|
||||
EgtInvertCurve( tabRibs[i][j])
|
||||
end
|
||||
end
|
||||
-- aggiorno bInvert per il gruppo di costolature successivo
|
||||
if LayerParams.bRibsLink and LayerParams.nRibsShellsNbr % 2 == 1 then
|
||||
bInvert = not bInvert
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Link
|
||||
-- se modifiche nell'ordine ricalcolo i gruppi di costolature
|
||||
if bSwap then
|
||||
tabRibs = {}
|
||||
nFirst = EgtGetFirstNameInGroup( nTpathGrpId, RIBS_CRV .. '*')
|
||||
while nFirst do
|
||||
local sName = EgtGetName( nFirst)
|
||||
local vIds = EgtGetNameInGroup( nTpathGrpId, sName)
|
||||
table.insert( tabRibs, vIds)
|
||||
nFirst = EgtGetNextName( vIds[#vIds], RIBS_CRV .. '*')
|
||||
end
|
||||
end
|
||||
|
||||
-- collego le passate di una stessa costolatura
|
||||
for i = 1, #tabRibs do
|
||||
for j = 1, #tabRibs[i] - 1 do
|
||||
local ptS = EgtEP( tabRibs[i][j])
|
||||
local ptE = EgtSP( tabRibs[i][j + 1])
|
||||
CalcRibsLink( ptS, ptE, tabRibs[i][j], nLoopGrp, true)
|
||||
CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, true)
|
||||
if not bSpecialCase then
|
||||
-- creo link fittizio per eliminare tratto corrispondente sulla curva di offset
|
||||
local nFakeLink = CalcRibsLink( EgtSP( tabRibs[i][j]), EgtEP( tabRibs[i][j + 1]), tabRibs[i][j], nLoopGrp, false)
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][j + 1], tabRibs[i][j], nLoopGrp, false)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
end
|
||||
if bSpecialCase then
|
||||
local nFakeLink = CalcRibsLink( EgtSP( tabRibs[i][1]), EgtEP( tabRibs[i][#tabRibs[i]]), tabRibs[i][1], nLoopGrp, false)
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][#tabRibs[i]], tabRibs[i][1], nLoopGrp, false)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
end
|
||||
@@ -485,9 +532,7 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
if LayerParams.bRibsLink then
|
||||
for i = 1, #tabRibs - 1 do
|
||||
local nCnt = #tabRibs[i]
|
||||
local ptS = EgtEP( tabRibs[i][nCnt])
|
||||
local ptE = EgtSP( tabRibs[i + 1][1])
|
||||
CalcRibsLink( ptS, ptE, tabRibs[i][nCnt], nLoopGrp, false)
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user