3dPrinting :
- migliorie nei setti ( ingressi, uscite e gestione intersezioni).
This commit is contained in:
@@ -31,6 +31,7 @@ TOT_SHELL_TRIM_SURF = "TotalShellSurfForTrim"
|
||||
|
||||
MIN_LEN = 0.1
|
||||
MIN_AREA = 0.01
|
||||
MIN_RIBS_LEN = 2
|
||||
|
||||
-- Parametri di lavorazione
|
||||
SEC_DEFAULT = "Default"
|
||||
|
||||
+73
-99
@@ -266,7 +266,7 @@ local function ReorderPath( vOldIds, vNewIds)
|
||||
EgtSpAddPoint( pt:getX(), pt:getY(), pt:getZ(), 0, 0, pt:getX(), pt:getY(), pt:getZ(), 0, 0)
|
||||
end
|
||||
local ptS = EgtSP( nParentIdx)
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, ptS:getX(), ptS:getY(), ptS:getZ(), 0, 0)
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, ptS:getX(), ptS:getY(), ptS:getZ(), 0, 0)
|
||||
local vOrd, _ = EgtSpCalculate( SHP_TY.OPEN)
|
||||
EgtSpTerminate()
|
||||
|
||||
@@ -385,37 +385,9 @@ end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
--------------------------- RIBS -----------------------------------
|
||||
--------------------------------------------------------------------
|
||||
local function TrimRibsOffset( nCrv, nOffs1, nOffs2, nOffsGrp, bIn)
|
||||
|
||||
local ptInt1 = EgtIP( nCrv, nOffs1, ORIG())
|
||||
local ptInt2 = EgtIP( nCrv, nOffs2, ORIG())
|
||||
local dPar1, dPar2
|
||||
if ptInt1 then dPar1 = EgtCurveParamAtPoint( nCrv, ptInt1) end
|
||||
if ptInt2 then dPar2 = EgtCurveParamAtPoint( nCrv, ptInt2) end
|
||||
|
||||
if dPar1 and dPar2 then
|
||||
-- la curva viene spezzata in tre parti
|
||||
if dPar1 > dPar2 then
|
||||
dPar1, dPar2 = dPar2, dPar1
|
||||
end
|
||||
local nCopy = EgtCopyGlob( nCrv, nOffsGrp)
|
||||
EgtTrimCurveEndAtParam( nCrv, dPar1)
|
||||
EgtTrimCurveStartAtParam( nCopy, dPar2)
|
||||
EgtSetInfo( nCopy, KEY_SPLIT_RIB, nCrv)
|
||||
|
||||
elseif dPar1 or dPar2 then
|
||||
if bIn then
|
||||
EgtTrimCurveEndAtParam( nCrv, dPar1 or dPar2)
|
||||
else
|
||||
EgtTrimCurveStartAtParam( nCrv, dPar1 or dPar2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- Funzione che sistema le intersezioni fra costolature nel caso generico
|
||||
local function AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nOffsGrp, bIn)
|
||||
local function AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nOffsGrp)
|
||||
|
||||
-- calcolo gli offset della curva principale ( nCrv1) da usare per trim
|
||||
local nShells = EgtGetInfo( nCrv1, KEY_RIBS_SHELLS_NBR, 'i')
|
||||
@@ -423,74 +395,66 @@ local function AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nOffs
|
||||
local nOverlap2 = EgtGetInfo( nCrv2, KEY_RIBS_OVERLAP, 'i')
|
||||
local nOverlap = min( nOverlap1, nOverlap2)
|
||||
local dOffs = ( nShells - 1) * LayerParams.dStrand / 2
|
||||
local nOffsM = EgtOffsetCurveAdv( nCrv1, - dOffs - ( 1 - nOverlap / 100) * LayerParams.dStrand)
|
||||
local nOffsP = EgtOffsetCurveAdv( nCrv1, dOffs + ( 1 - nOverlap / 100) * LayerParams.dStrand)
|
||||
local vSplit = {}
|
||||
local nSrf = EgtSurfFrFatCurve( nOffsGrp, nCrv1, dOffs + ( 1 - nOverlap / 100) * LayerParams.dStrand, false)
|
||||
|
||||
-- recupero gli offset della curva secondaria ( nCrv2)
|
||||
local vOffs2 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv2))
|
||||
-- trim degli offset della curva secondaria
|
||||
for i = 1, #vOffs2 do
|
||||
TrimRibsOffset( vOffs2[i], nOffsM, nOffsP, nOffsGrp, bIn)
|
||||
end
|
||||
|
||||
EgtErase( nOffsM)
|
||||
EgtErase( nOffsP)
|
||||
local nId, nCnt = EgtTrimCurveWithRegion( vOffs2[i], nSrf, false, true)
|
||||
EgtChangeId( nId, vOffs2[i])
|
||||
if nCnt > 1 then
|
||||
EgtSetInfo( nId + 1, KEY_SPLIT_RIB, vOffs2[i])
|
||||
EgtRelocateGlob( nId + 1, nOffsGrp, GDB_IN.LAST_SON)
|
||||
end
|
||||
end
|
||||
EgtErase( nSrf)
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- Funzione che sistema le intersezioni fra costolature nel caso di 2 passate
|
||||
local function AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nOffsGrp, bIn)
|
||||
local function AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nOffsGrp, nOrigGrp)
|
||||
|
||||
-- recupero gli offset delle due curve
|
||||
local vOffs1 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv1))
|
||||
local vOffs2 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv2))
|
||||
-- recupero gli offset originali delle due curve
|
||||
local vOffsOrig1 = EgtGetNameInGroup( nOrigGrp, EgtGetName( nCrv1))
|
||||
local vOffsOrig2 = EgtGetNameInGroup( nOrigGrp, EgtGetName( nCrv2))
|
||||
|
||||
local vCopy1 = {}
|
||||
for i = 1, #vOffs1 do
|
||||
local nId = EgtCopyGlob( vOffs1[i], nOffsGrp)
|
||||
table.insert( vCopy1, nId)
|
||||
-- costruisco le superfici da usare per trim
|
||||
local nOverlap = EgtGetInfo( nCrv1, KEY_RIBS_OVERLAP, 'i')
|
||||
local dOffs = LayerParams.dStrand / 2 + ( 1 - nOverlap / 100) * LayerParams.dStrand
|
||||
|
||||
local nRect1 = EgtRectangle3P( nOffsGrp, EgtSP( vOffsOrig1[1]), EgtEP( vOffsOrig1[2]), EgtEP( vOffsOrig1[1]))
|
||||
local nSrf1 = EgtSurfFlatRegion( nOffsGrp, {nRect1})
|
||||
local vtN1 = EgtSurfFrNormVersor( nSrf1, GDB_ID.ROOT)
|
||||
if LayerParams.vtSlicing * vtN1 < 0 then
|
||||
EgtInvertSurf( nSrf1)
|
||||
end
|
||||
|
||||
|
||||
local nRect2 = EgtRectangle3P( nOffsGrp, EgtSP( vOffsOrig2[1]), EgtEP( vOffsOrig2[2]), EgtEP( vOffsOrig2[1]))
|
||||
local nSrf2 = EgtSurfFlatRegion( nOffsGrp, {nRect2})
|
||||
local vtN2 = EgtSurfFrNormVersor( nSrf2, GDB_ID.ROOT)
|
||||
if LayerParams.vtSlicing * vtN2 < 0 then
|
||||
EgtInvertSurf( nSrf2)
|
||||
end
|
||||
|
||||
-- trim degli offset di nCrv1
|
||||
local vOffs1 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv1))
|
||||
for i = 1, #vOffs1 do
|
||||
-- trovo gli offset di nCrv2 coinvolti nell'intersezione
|
||||
local vIds = {}
|
||||
for j = 1, #vOffs2 do
|
||||
local ptInt = EgtIP( vOffs1[i], vOffs2[j], ORIG())
|
||||
if ptInt then table.insert( vIds, j) end
|
||||
end
|
||||
if #vIds > 0 then
|
||||
local bInCrv1 = false
|
||||
-- se viene trovata una sola intersezione devo calcolare bIn per nCrv1
|
||||
if #vIds == 1 then
|
||||
table.insert( vIds, EgtIf( vIds[1] == 1, 2, 1))
|
||||
local ptInt = EgtIP( nCrv1, nCrv2, ORIG())
|
||||
local dParInt = EgtCurveParamAtPoint( nCrv1, ptInt)
|
||||
local _, dParE = EgtCurveDomain( nCrv1)
|
||||
bInCrv1 = abs( dParInt - dParE) < 100 * GEO.EPS_SMALL
|
||||
end
|
||||
TrimRibsOffset( vOffs1[i], vOffs2[vIds[1]], vOffs2[vIds[2]], nOffsGrp, bInCrv1)
|
||||
end
|
||||
|
||||
end
|
||||
local nId, nCnt = EgtTrimCurveWithRegion( vOffs1[i], nSrf2, false, true)
|
||||
end
|
||||
|
||||
-- trim degli offset di nCrv2
|
||||
local vOffs2 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv2))
|
||||
for i = 1, #vOffs2 do
|
||||
-- trovo gli offset di nCrv1 coinvolti nell'intersezione
|
||||
local vIds = {}
|
||||
for j = 1, #vCopy1 do
|
||||
local ptInt = EgtIP( vOffs2[i], vCopy1[j], ORIG())
|
||||
if ptInt then table.insert( vIds, j) end
|
||||
end
|
||||
if #vIds > 0 then
|
||||
if #vIds == 1 then table.insert( vIds, EgtIf( vIds[1] == 1, 2, 1)) end
|
||||
TrimRibsOffset( vOffs2[i], vCopy1[vIds[1]], vCopy1[vIds[2]], nOffsGrp, bIn)
|
||||
end
|
||||
local nId, nCnt = EgtTrimCurveWithRegion( vOffs2[i], nSrf1, false, true)
|
||||
end
|
||||
|
||||
for i = 1, #vCopy1 do
|
||||
EgtErase( vCopy1[i])
|
||||
end
|
||||
EgtErase( nSrf1)
|
||||
EgtErase( nRect1)
|
||||
EgtErase( nSrf2)
|
||||
EgtErase( nRect2)
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
@@ -527,20 +491,19 @@ local function HandleRibsIntersections( nRibsGrp, LayerParams, nOffsGrp, nRibsPa
|
||||
local dPar1 = EgtCurveParamAtPoint( vRibsIds[i], ptInt)
|
||||
local dPar2 = EgtCurveParamAtPoint( vRibsIds[j], ptInt)
|
||||
local _, dParE1 = EgtCurveDomain( vRibsIds[i])
|
||||
local _, dParE2 = EgtCurveDomain( vRibsIds[j])
|
||||
local _, dParE2 = EgtCurveDomain( vRibsIds[j])
|
||||
|
||||
local bIn = abs( dPar1 - dParE1) < 50 * GEO.EPS_SMALL or abs( dPar2 - dParE2) < 50 * GEO.EPS_SMALL
|
||||
local nCrv1 = vRibsIds[i] -- curva principale che non viene tagliata
|
||||
local nCrv2 = vRibsIds[j] -- curve secondaria da modificare
|
||||
if dPar1 < 50 * GEO.EPS_SMALL or abs( dPar1 - dParE1) < 50 * GEO.EPS_SMALL then
|
||||
if dPar1 < 10 * GEO.EPS_SMALL or abs( dPar1 - dParE1) < 10 * GEO.EPS_SMALL then
|
||||
nCrv1, nCrv2 = nCrv2, nCrv1
|
||||
end
|
||||
|
||||
if bAllTwoStrands then
|
||||
-- nel caso di 2 passate gestione speciale
|
||||
AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nRibsPathGrp, bIn)
|
||||
AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nRibsPathGrp, nOffsGrp)
|
||||
else
|
||||
AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nRibsPathGrp, bIn)
|
||||
AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nRibsPathGrp)
|
||||
end
|
||||
end
|
||||
EgtErase( nPtId)
|
||||
@@ -575,6 +538,10 @@ local function ReorderRibs( nGrp, bInvertOrder, dStrand, nMaxNbr)
|
||||
table.insert( vSPRibs, vIds[i])
|
||||
end
|
||||
end
|
||||
|
||||
local ptS = ORIG()
|
||||
EgtSpSetOpenBound( true, SHP_OB.NEAR_PNT, ptS:getX(), ptS:getY(), ptS:getZ(), 0, 0)
|
||||
|
||||
local vOrd, dLen = EgtSpCalculate( SHP_TY.OPEN)
|
||||
EgtSpTerminate()
|
||||
|
||||
@@ -585,12 +552,14 @@ local function ReorderRibs( nGrp, bInvertOrder, dStrand, nMaxNbr)
|
||||
|
||||
-- sistemo nomi
|
||||
local kMax = nMaxNbr + 1
|
||||
local dTol = 500 * GEO.EPS_SMALL
|
||||
for i = 1, nMaxNbr do
|
||||
local vIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. tostring(i)) or {}
|
||||
for j = 2, #vIds do
|
||||
local ptM = EgtMP( vIds[j])
|
||||
local dDist = EgtPointCurveDist( ptM, vIds[j-1])
|
||||
if abs( dDist - dStrand) < 20 * GEO.EPS_SMALL then
|
||||
local dDistS = EgtPointCurveDist( EgtSP( vIds[j]), vIds[j-1])
|
||||
local dDistM = EgtPointCurveDist( EgtMP( vIds[j]), vIds[j-1])
|
||||
local dDistE = EgtPointCurveDist( EgtEP( vIds[j]), vIds[j-1])
|
||||
if abs( dDistS - dStrand) < dTol or abs( dDistM - dStrand) < dTol or abs( dDistE - dStrand) < dTol then
|
||||
-- se le costolatura è vicina alla precedente avrà lo stesso nome
|
||||
EgtSetName( vIds[j], EgtGetName( vIds[j-1]))
|
||||
EgtRelocateGlob( vIds[j], vIds[j-1], GDB_IN.AFTER)
|
||||
@@ -695,7 +664,7 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
-- prendo la prima tra le curve a disposizione
|
||||
nCurrCrv = vIds[1]
|
||||
table.remove( vIds, 1)
|
||||
EgtSetName( nCurrCrv, RIBS_CRV .. tostring(k))
|
||||
EgtSetName( nCurrCrv, RIBS_CRV .. tostring(k))
|
||||
local pt = EgtEP( nCurrCrv)
|
||||
local _, dParE = EgtCurveDomain( nCurrCrv)
|
||||
local nCnt = 0
|
||||
@@ -713,7 +682,7 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
-- controllo che sia vicino ad uno degli estremi
|
||||
local dParS, dParE = EgtCurveDomain( vIds[j])
|
||||
if abs( dParMinDist - dParS) < 500 * GEO.EPS_SMALL then
|
||||
bAdd = true
|
||||
bAdd = true
|
||||
elseif abs( dParMinDist - dParE) < 500 * GEO.EPS_SMALL then
|
||||
bAdd = true
|
||||
-- è se necessaria inversione di vIds[j]
|
||||
@@ -769,7 +738,12 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
end
|
||||
end
|
||||
-- se non ho più curve da collegare
|
||||
if not bFound then
|
||||
if not bFound and nCnt == 0 then
|
||||
-- se era la prima curva faccio un tentativo invertendola
|
||||
nCnt = 1
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
pt = EgtEP( nCurrCrv)
|
||||
elseif not bFound then
|
||||
nCurrCrv = nil
|
||||
end
|
||||
end
|
||||
@@ -848,13 +822,13 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, nMaxStrand
|
||||
EgtOutLog( 'Warning: Ribs not possibile (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
EgtErase( vOrderedRibs[i])
|
||||
else
|
||||
local nCrv, nCnt = EgtTrimCurveWithRegion( vOrderedRibs[i], vSurfOffs[nOverlap], true, false)
|
||||
tOldNewIds[ vOrderedRibs[i]] = {}
|
||||
|
||||
-- elimino tratti troppo corti
|
||||
for nInd = 0, nCnt - 1 do
|
||||
local nCrv, nCnt = EgtTrimCurveWithRegion( vOrderedRibs[i], vSurfOffs[nOverlap], true, false)
|
||||
tOldNewIds[ vOrderedRibs[i]] = {}
|
||||
|
||||
-- elimino tratti troppo corti
|
||||
for nInd = 0, nCnt - 1 do
|
||||
local dLen = EgtCurveLength( nCrv + nInd)
|
||||
if dLen < 10 * MIN_LEN then
|
||||
if dLen < MIN_RIBS_LEN then
|
||||
EgtErase( nCrv + nInd)
|
||||
else
|
||||
table.insert( tOldNewIds[ vOrderedRibs[i]], nCrv + nInd)
|
||||
@@ -871,7 +845,7 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, nMaxStrand
|
||||
|
||||
-- salvo info della superficie di trim associata
|
||||
EgtSetInfo( nCrv + nInd, KEY_ASSOCIATED_SURF, vSurfOffs[nOverlap])
|
||||
|
||||
|
||||
if nInd == 0 then
|
||||
-- aggiorno la info
|
||||
local nInfo = EgtGetInfo( nCrv + nInd, KEY_SPLIT_RIB, 'i')
|
||||
@@ -887,7 +861,7 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, nMaxStrand
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+215
-122
@@ -298,31 +298,17 @@ local function VerifyRibsLink( nLinkId, nCurr, nNext, dStrand)
|
||||
return false
|
||||
end
|
||||
|
||||
-- regione occupata dal link
|
||||
local nTotLink = EgtCopyGlob( nLinkId, nGrp)
|
||||
local nCopy = EgtCopyGlob( nLinkId, nGrp)
|
||||
EgtInvertCurve( nCopy)
|
||||
EgtAddCurveCompoCurve( nTotLink, nCopy)
|
||||
local nOffs = EgtOffsetCurveAdv( nTotLink, dStrand * 0.5)
|
||||
if not nOffs or nOffs == GDB_ID.NULL then
|
||||
nOffs = nTotLink
|
||||
end
|
||||
|
||||
-- verifico se il link interseca una delle altre costolature
|
||||
local vRibsIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. '*')
|
||||
for i = 1, #vRibsIds do
|
||||
if vRibsIds[i] ~= nCurr and vRibsIds[i] ~= nNext then
|
||||
local ptInt = EgtIP( nOffs, vRibsIds[i], ORIG())
|
||||
local ptInt2 = EgtIP( nLinkId, vRibsIds[i], ORIG())
|
||||
if ptInt or ptInt2 then
|
||||
EgtErase( nOffs)
|
||||
EgtErase( nTotLink)
|
||||
local ptInt = EgtIP( nLinkId, vRibsIds[i], ORIG())
|
||||
if ptInt then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nOffs)
|
||||
EgtErase( nTotLink)
|
||||
return true
|
||||
end
|
||||
@@ -407,7 +393,174 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, dStrand, bForceLink)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRibsLeadIn( nCrv, nLoopsGrp)
|
||||
local function VerifyRibsLead( nId, nRibId, dStrand, bInVsOut)
|
||||
|
||||
local nGrp = EgtGetParent( nRibId)
|
||||
local nLeadId = EgtCopyGlob( nId, nGrp)
|
||||
if bInVsOut then
|
||||
EgtExtendCurveStartByLen( nLeadId, dStrand * 0.5)
|
||||
else
|
||||
EgtExtendCurveEndByLen( nLeadId, dStrand * 0.5)
|
||||
end
|
||||
|
||||
-- verifico che intersechi solo l'estrmo corretto
|
||||
local pt = EgtIf( bInVsOut, EgtEP( nRibId), EgtSP( nRibId))
|
||||
local dPar = EgtCurveParamAtPoint( nLeadId, pt)
|
||||
if dPar then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
|
||||
local pt1 = EgtIf( bInVsOut, EgtSP( nLeadId), EgtEP( nLeadId))
|
||||
local pt2 = EgtIf( bInVsOut, EgtEP( nRibId), EgtSP( nRibId))
|
||||
if dist( pt1, pt2) < dStrand + GEO.EPS_SMALL then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
|
||||
local _, dParE = EgtCurveDomain( nLeadId)
|
||||
local vtDir = EgtMV( nRibId)
|
||||
local dParCrv = 1
|
||||
local dTol = 10 * GEO.EPS_SMALL
|
||||
for dParCrv = 1, dParE do
|
||||
local vtS = EgtUV( nLeadId, dParCrv - 1, 1)
|
||||
local vtE = EgtUV( nLeadId, dParCrv, -1)
|
||||
-- se tratto lineare allineato con la direzione del setto verifico sia sufficientemente lontano
|
||||
if AreSameVectorApprox( vtS, vtE) and ( (vtS - vtDir):sqlen() < dTol * dTol or (vtS + vtDir):sqlen() < dTol * dTol) then
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLeadId, dParCrv - 0.5), nRibId)
|
||||
if dDist < dStrand + GEO.EPS_SMALL then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico non intersechi altri setti
|
||||
local vRibsIds = EgtGetNameInGroup( EgtGetParent( nRibId), RIBS_CRV .. '*')
|
||||
for i = 1, #vRibsIds do
|
||||
if vRibsIds[i] ~= nRibId then
|
||||
local ptInt = EgtIP( nLeadId, vRibsIds[i], ORIG())
|
||||
if ptInt then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- se lead out verifico non si sovrapponga al lead in
|
||||
if not bInVsOut then
|
||||
-- recupero il lead in
|
||||
local nPrev = EgtGetPrev( nRibId)
|
||||
if nPrev and EgtGetName( nPrev) == LEAD_IN_CRV then
|
||||
local nSrfTot = EgtSurfFrFatCurve( EgtGetParent( nLeadId), nPrev, 0.5 * dStrand, false)
|
||||
if nSrfTot then
|
||||
local nRes = EgtCurveWithRegionClassify( nLeadId, nSrfTot)
|
||||
if nRes == GDB_CRC.IN or nRes == GDB_CRC.INTERS then
|
||||
EgtErase( nSrfTot)
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
else
|
||||
nSrfTot = EgtSurfFrFatCurve( EgtGetParent( nLeadId), nLeadId, 0.5 * dStrand, false)
|
||||
if nSrfTot then
|
||||
local nRes = EgtCurveWithRegionClassify( nPrev, nSrfTot)
|
||||
if nRes == GDB_CRC.IN or nRes == GDB_CRC.INTERS then
|
||||
EgtErase( nSrfTot)
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
EgtErase( nSrfTot)
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nLeadId)
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
local function FindCorrectRibsLead( dPar, nCrv, nCrvOffs, bLeadInvert, dLeadLen, dStrand, bInVsOut)
|
||||
|
||||
local nLeadId
|
||||
local bInvert = bLeadInvert -- valore di default è quello settato nel file dei parametri
|
||||
|
||||
local _, dParEnd = EgtCurveDomain( nCrvOffs)
|
||||
local bClosed = EgtCurveIsClosed( nCrvOffs)
|
||||
local bOnlyOneCurve = not bClosed and ( dPar < GEO.EPS_SMALL or abs( dPar - dParEnd) < GEO.EPS_SMALL)
|
||||
|
||||
local nMainCrv = nCrvOffs -- curva preferita da utilizzare per lead in
|
||||
local nOtherCrv -- altra possibile curva da ultizzare nel caso nMainCrv non sia adatta
|
||||
|
||||
if bClosed then
|
||||
EgtChangeClosedCurveStart( nCrvOffs, dPar)
|
||||
nOtherCrv = nCrvOffs
|
||||
elseif not bOnlyOneCurve then
|
||||
nOtherCrv = EgtSplitCurveAtParam( nCrvOffs, dPar)
|
||||
end
|
||||
|
||||
-- calcolo del parametro bInvert
|
||||
if bOnlyOneCurve then
|
||||
-- invert dipende dall'estremo da cui parte il setto
|
||||
bInvert = abs( dPar - dParEnd) < GEO.EPS_SMALL
|
||||
elseif not bClosed then
|
||||
-- invert può essere legato anche alla lunghezza dei tratti possibili
|
||||
local dLen1 = EgtCurveLength( nMainCrv)
|
||||
local dLen2 = EgtCurveLength( nOtherCrv)
|
||||
if dLen1 > dLeadLen - GEO.EPS_SMALL and dLen2 < dLeadLen - GEO.EPS_SMALL then
|
||||
bInvert = true
|
||||
elseif dLen1 < dLeadLen - GEO.EPS_SMALL and dLen2 > dLeadLen - GEO.EPS_SMALL then
|
||||
bInvert = false
|
||||
end
|
||||
|
||||
if not bInvert then
|
||||
nMainCrv, nOtherCrv = nOtherCrv, nMainCrv
|
||||
end
|
||||
end
|
||||
|
||||
-- primo tentativo con la curva favorita
|
||||
nLeadId = EgtCopyGlob( nMainCrv, nCrv, EgtIf( bInVsOut, GDB_IN.BEFORE, GDB_IN.AFTER))
|
||||
if bInvert then EgtInvertCurve( nLeadId) end
|
||||
EgtTrimCurveEndAtLen( nLeadId, dLeadLen)
|
||||
if bInVsOut then EgtInvertCurve( nLeadId) end
|
||||
if VerifyRibsLead( nLeadId, nCrv, dStrand, bInVsOut) then
|
||||
-- se valido aggiorno le curve per prossimi lead in/out
|
||||
if bInvert then
|
||||
EgtTrimCurveEndAtLen( nMainCrv, EgtCurveLength( nCrvOffs) - dLeadLen)
|
||||
else
|
||||
EgtTrimCurveStartAtLen( nMainCrv, dLeadLen)
|
||||
end
|
||||
elseif not nOtherCrv then
|
||||
-- se non è valido e non ho altre curve possibili cancello
|
||||
EgtErase( nLeadId)
|
||||
return nil
|
||||
else
|
||||
-- se non è valido ma ho altra curva possibile, tento con quella
|
||||
EgtErase( nLeadId)
|
||||
nLeadId = EgtCopyGlob( nOtherCrv, nCrv, EgtIf( bInVsOut, GDB_IN.BEFORE, GDB_IN.AFTER))
|
||||
if not bInvert then EgtInvertCurve( nLeadId) end
|
||||
EgtTrimCurveEndAtLen( nLeadId, dLeadLen)
|
||||
if bInVsOut then EgtInvertCurve( nLeadId) end
|
||||
if VerifyRibsLead( nLeadId, nCrv, dStrand, bInVsOut) then
|
||||
if bInvert then
|
||||
EgtTrimCurveStartAtLen( nOtherCrv, dLeadLen)
|
||||
else
|
||||
EgtTrimCurveEndAtLen( nOtherCrv, EgtCurveLength( nCrvOffs) - dLeadLen)
|
||||
end
|
||||
else
|
||||
EgtErase( nLeadId)
|
||||
bInvert = not bInvert
|
||||
return nil
|
||||
end
|
||||
-- aggiorno parametro bInvert
|
||||
bInvert = not bInvert
|
||||
end
|
||||
|
||||
return nLeadId, bInvert
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRibsLeadIn( nCrv, nLoopsGrp, dStrand)
|
||||
|
||||
local dLILen = EgtGetInfo( nCrv, KEY_RIBS_LEAD_IN_LEN, 'd')
|
||||
local bLIInvert = EgtGetInfo( nCrv, KEY_RIBS_LEAD_IN_INVERT, 'b')
|
||||
@@ -420,44 +573,13 @@ local function AddRibsLeadIn( nCrv, nLoopsGrp)
|
||||
while nCrvOffs do
|
||||
local dParS = EgtCurveParamAtPoint( nCrvOffs, ptS)
|
||||
if dParS then
|
||||
local nCrvId = EgtCopyGlob( nCrvOffs, nCrv, GDB_IN.BEFORE)
|
||||
local bClosed = EgtCurveIsClosed( nCrvId)
|
||||
if bClosed then
|
||||
EgtChangeClosedCurveStart( nCrvId, dParS)
|
||||
dParS = 0
|
||||
end
|
||||
|
||||
-- scelgo il lato da cui fare ingresso
|
||||
local _, dEndPar = EgtCurveDomain( nCrvId)
|
||||
-- se ho solo un tratto possibile verifico se va invertito
|
||||
if abs( dParS - dEndPar) < GEO.EPS_SMALL then
|
||||
EgtInvertCurve( nCrvId)
|
||||
elseif abs( dParS) > GEO.EPS_SMALL or bClosed then
|
||||
-- se ho più tratti possibili scelgo in base al parametro RibsLIInvert o alle dimensioni
|
||||
local nNewId = EgtSplitCurveAtParam( nCrvId, dParS) or EgtCopyGlob( nCrvId, nCrv, GDB_IN.BEFORE)
|
||||
local dLen1 = EgtCurveLength( nCrvId)
|
||||
local dLen2 = EgtCurveLength( nNewId)
|
||||
|
||||
local bKeepFirst = bLIInvert
|
||||
if dLen1 > dLILen - GEO.EPS_SMALL and dLen2 < dLILen - GEO.EPS_SMALL then
|
||||
bKeepFirst = true
|
||||
elseif dLen1 < dLILen - GEO.EPS_SMALL and dLen2 > dLILen - GEO.EPS_SMALL then
|
||||
bKeepFirst = false
|
||||
end
|
||||
|
||||
if bKeepFirst then
|
||||
EgtInvertCurve( nCrvId)
|
||||
EgtErase( nNewId)
|
||||
else
|
||||
EgtErase( nCrvId)
|
||||
nCrvId = nNewId
|
||||
end
|
||||
end
|
||||
|
||||
EgtTrimCurveEndAtLen( nCrvId, dLILen)
|
||||
EgtInvertCurve( nCrvId)
|
||||
EgtSetInfo( nCrvId, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nCrvId, LEAD_IN_CRV)
|
||||
local nLeadIn = FindCorrectRibsLead( dParS, nCrv, nCrvOffs, bLIInvert, dLILen, dStrand, true)
|
||||
-- se lead in possibile
|
||||
if nLeadIn then
|
||||
EgtSetInfo( nLeadIn, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLeadIn, LEAD_IN_CRV)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
@@ -466,7 +588,7 @@ local function AddRibsLeadIn( nCrv, nLoopsGrp)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing)
|
||||
local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand)
|
||||
|
||||
local dRibsLOLen = EgtGetInfo( nCrv, KEY_RIBS_LEAD_OUT_LEN, 'd')
|
||||
local dRibsLOCoasting = EgtGetInfo( nCrv, KEY_RIBS_LEAD_OUT_COASTING, 'd')
|
||||
@@ -479,6 +601,8 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing)
|
||||
abs( dRibsLOWipe) < GEO.EPS_SMALL then return end
|
||||
|
||||
local ptE = EgtEP( nCrv)
|
||||
local vtE = EgtEV( nCrv)
|
||||
|
||||
-- recupero la curva di offset su cui calcolare lead out
|
||||
local nCrvOffs = EgtGetFirstInGroup( nLoopsGrp)
|
||||
while nCrvOffs do
|
||||
@@ -488,73 +612,42 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing)
|
||||
local nCrvLO
|
||||
local nCoasting
|
||||
local nWipe
|
||||
local bInvert = false
|
||||
|
||||
local nCrvRef = EgtCopyGlob( nCrvOffs, nCrv, GDB_IN.AFTER)
|
||||
local bClosed = EgtCurveIsClosed( nCrvRef)
|
||||
if bClosed then
|
||||
EgtChangeClosedCurveStart( nCrvRef, dParE)
|
||||
dParE = 0
|
||||
end
|
||||
|
||||
-- scelgo il lato da cui fare uscita
|
||||
local _, dEndPar = EgtCurveDomain( nCrvRef)
|
||||
-- se ho solo un tratto possibile verifico se va invertito
|
||||
if abs( dParE - dEndPar) < GEO.EPS_SMALL then
|
||||
EgtInvertCurve( nCrvRef)
|
||||
bInvert = true
|
||||
elseif abs( dParE) > GEO.EPS_SMALL or bClosed then
|
||||
-- se ho più tratti possibili scelgo in base al parametro RibsLOInvert o alle dimensioni
|
||||
local nNewId = EgtSplitCurveAtParam( nCrvRef, dParE) or EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER)
|
||||
local dLen1 = EgtCurveLength( nCrvRef)
|
||||
local dLen2 = EgtCurveLength( nNewId)
|
||||
bInvert = bRibsLOInvert
|
||||
if dLen1 > dRibsLOLen + dRibsLOCoasting - GEO.EPS_SMALL and dLen2 < dRibsLOLen + dRibsLOCoasting - GEO.EPS_SMALL then
|
||||
bInvert = true
|
||||
elseif dLen1 < dRibsLOLen + dRibsLOCoasting - GEO.EPS_SMALL and dLen2 > dRibsLOLen + dRibsLOCoasting - GEO.EPS_SMALL then
|
||||
bInvert = false
|
||||
end
|
||||
|
||||
if bInvert then
|
||||
EgtInvertCurve( nCrvRef)
|
||||
EgtErase( nNewId)
|
||||
else
|
||||
EgtErase( nCrvRef)
|
||||
nCrvRef = nNewId
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se la curva ha lunghezza sufficiente
|
||||
local dLen = EgtCurveLength( nCrvRef)
|
||||
local bSkip = ( dLen - dRibsLOLen - dRibsLOCoasting < - GEO.EPS_SMALL)
|
||||
local vtE = EgtEV( nCrv)
|
||||
-- trovo curva opportuna per lead out
|
||||
local nCrvRef, bInvert = FindCorrectRibsLead( dParE, nCrv, nCrvOffs, bRibsLOInvert, dRibsLOLen + dRibsLOCoasting, dStrand, false)
|
||||
|
||||
-- primo tratto ( segue offset con flusso aperto)
|
||||
if dRibsLOLen > GEO.EPS_SMALL and not bSkip then
|
||||
nCrvLO = EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER)
|
||||
EgtTrimCurveEndAtLen( nCrvLO, dRibsLOLen)
|
||||
EgtSetInfo( nCrvLO, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nCrvLO, LEAD_OUT_CRV)
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nCrvLO)
|
||||
vtE = EgtEV( nCrvLO)
|
||||
end
|
||||
|
||||
-- secondo tratto ( segue offset con flusso chiuso)
|
||||
if dRibsLOCoasting > GEO.EPS_SMALL and not bSkip then
|
||||
nCoasting = EgtCopyGlob( nCrvRef, nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartAtLen( nCoasting, dRibsLOLen)
|
||||
EgtTrimCurveEndAtLen( nCoasting, dRibsLOCoasting)
|
||||
|
||||
EgtSetName( nCoasting, COASTING_CRV)
|
||||
EgtSetInfo( nCoasting, KEY_TYPE, TYPE.COASTING)
|
||||
EgtSetColor( nCoasting, EgtStdColor('ORANGE'))
|
||||
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nCoasting)
|
||||
vtE = EgtEV( nCoasting)
|
||||
if nCrvRef then
|
||||
-- verifico se la curva ha lunghezza sufficiente
|
||||
local dLen = EgtCurveLength( nCrvRef)
|
||||
local bSkip = ( dLen - dRibsLOLen - dRibsLOCoasting < - GEO.EPS_SMALL)
|
||||
|
||||
-- primo tratto ( segue offset con flusso aperto)
|
||||
if dRibsLOLen > GEO.EPS_SMALL and not bSkip then
|
||||
nCrvLO = EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER)
|
||||
EgtTrimCurveEndAtLen( nCrvLO, dRibsLOLen)
|
||||
EgtSetInfo( nCrvLO, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nCrvLO, LEAD_OUT_CRV)
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nCrvLO)
|
||||
vtE = EgtEV( nCrvLO)
|
||||
end
|
||||
|
||||
-- secondo tratto ( segue offset con flusso chiuso)
|
||||
if dRibsLOCoasting > GEO.EPS_SMALL then
|
||||
nCoasting = EgtCopyGlob( nCrvRef, nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartAtLen( nCoasting, dRibsLOLen)
|
||||
EgtTrimCurveEndAtLen( nCoasting, dRibsLOCoasting)
|
||||
|
||||
EgtSetName( nCoasting, COASTING_CRV)
|
||||
EgtSetInfo( nCoasting, KEY_TYPE, TYPE.COASTING)
|
||||
EgtSetColor( nCoasting, EgtStdColor('ORANGE'))
|
||||
|
||||
-- aggiorno ptE e vtE
|
||||
ptE = EgtEP( nCoasting)
|
||||
vtE = EgtEV( nCoasting)
|
||||
end
|
||||
EgtErase( nCrvRef)
|
||||
end
|
||||
EgtErase( nCrvRef)
|
||||
|
||||
-- terzo tratto ( diretto verso esterno con ugello chiuso)
|
||||
if dRibsLOWipe > GEO.EPS_SMALL then
|
||||
@@ -566,7 +659,7 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing)
|
||||
EgtRelocateGlob( nWipe, nCoasting or nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
EgtSetName( nWipe, WIPE_CRV)
|
||||
EgtSetInfo( nWipe, KEY_TYPE, TYPE.WIPE)
|
||||
EgtSetColor( nWipe, EgtStdColor('TEAL'))
|
||||
EgtSetColor( nWipe, EgtStdColor('TEAL'))
|
||||
end
|
||||
|
||||
return
|
||||
@@ -697,12 +790,12 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
-- verifico se necessario lead in
|
||||
local nPrev = EgtGetPrev( nCrvRib)
|
||||
if not nPrev or EgtGetName( nPrev) then
|
||||
AddRibsLeadIn( nCrvRib, nLoopGrp)
|
||||
AddRibsLeadIn( nCrvRib, nLoopGrp, LayerParams.dStrand)
|
||||
end
|
||||
-- verifico se necessario lead out
|
||||
local nNext = EgtGetNext( nCrvRib)
|
||||
if not nNext or EgtGetName( nNext) then
|
||||
AddRibsLeadOut( nCrvRib, nTpathGrpId, nLoopGrp, LayerParams.vtSlicing)
|
||||
AddRibsLeadOut( nCrvRib, nTpathGrpId, nLoopGrp, LayerParams.vtSlicing, LayerParams.dStrand)
|
||||
end
|
||||
nCrvRib = EgtGetNextName( nCrvRib, RIBS_CRV .. '*')
|
||||
end
|
||||
|
||||
@@ -139,8 +139,8 @@ local function LoadParams( sFile, nPartId)
|
||||
|
||||
-- parametri per regioni con diverso numero di passate
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_DIFF, '0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_COASTING, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_WIPE, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_COASTING, EgtGetInfo( nPartId, KEY_COASTING_LEN, 'd'))
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_WIPE, EgtGetInfo( nPartId, KEY_WIPE_LEN, 'd'))
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_WIPE_DIR, '0.0')
|
||||
|
||||
-- parametri per solidi ausiliari
|
||||
@@ -173,8 +173,8 @@ local function LoadParams( sFile, nPartId)
|
||||
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_LINK_PARAM, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_SP_OFFSET, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_COASTING_LEN, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_WIPE_LEN, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_COASTING_LEN, EgtGetInfo( nPartId, KEY_COASTING_LEN, 'd'))
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_WIPE_LEN, EgtGetInfo( nPartId, KEY_WIPE_LEN, 'd'))
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_AUX_SOLIDS_WIPE_DIR, '0.0')
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user