3dPrinting :
- gestione regioni con numero diverso di passate.
This commit is contained in:
+19
-7
@@ -18,6 +18,7 @@ SOLID_GRP = "Solid"
|
||||
TOOLPATH_GRP = "ToolPath"
|
||||
LAYER_SRF = "LayerSurf"
|
||||
SHELL_CRV = "Shell"
|
||||
EXTRA_SHELL_CRV = "ExtraShell"
|
||||
INFILL_CRV = "Infill"
|
||||
COASTING_CRV = "Coasting"
|
||||
WIPE_CRV = "Wipe"
|
||||
@@ -25,6 +26,8 @@ LEAD_IN_CRV = "LeadIn"
|
||||
LEAD_OUT_CRV = "LeadOut"
|
||||
FRAME_PART = "FramePart"
|
||||
START_GEOM = "Start"
|
||||
SHELL_NBR_SURF = "ShellNbrSurf"
|
||||
TOT_SHELL_TRIM_SURF = "TotalShellSurfForTrim"
|
||||
|
||||
MIN_LEN = 0.1
|
||||
MIN_AREA = 0.01
|
||||
@@ -86,6 +89,11 @@ KEY_RIBS_INTERS = "RibsHaveIntersections"
|
||||
KEY_SPLIT_RIB = "SplitRib"
|
||||
KEY_RIBS_TWO_STRANDS = "RibsHaveAll2Strands"
|
||||
|
||||
-- Regioni con diverso numero di passate
|
||||
KEY_SHELL_NBR_DIFF = "ShellNbrDifference"
|
||||
KEY_INVERTED_CURVE = "CurveIsInverted"
|
||||
KEY_CLOSED_EXTRA_SHELL = "ExtraShellIsClosed"
|
||||
|
||||
-- Parametri di macchina
|
||||
SEC_3DPRINTING = "3dPrinting"
|
||||
KEY_COEFF_X = "CoeffX"
|
||||
@@ -100,11 +108,13 @@ KEY_SLICE_REAL_Z = "SliceRealZ"
|
||||
TYPE = {
|
||||
OUTER_SHELL = 1,
|
||||
INNER_SHELL = 2,
|
||||
INFILL = 3,
|
||||
LINK = 4,
|
||||
COASTING = 5,
|
||||
WIPE = 6,
|
||||
RIB = 7,
|
||||
EXTRA_SHELL = 3,
|
||||
INFILL = 4,
|
||||
LINK = 5,
|
||||
COASTING = 6,
|
||||
WIPE = 7,
|
||||
RIB = 8,
|
||||
AUX_SOLID = 9,
|
||||
}
|
||||
|
||||
PRINT_ORDER = {
|
||||
@@ -189,9 +199,11 @@ SLICE_ADV_TYPE = {
|
||||
}
|
||||
|
||||
---------------------------------------------------------------------
|
||||
RIBS_GRP="Ribs"
|
||||
RIBS_CRV="Rib"
|
||||
RIBS_GRP = "Ribs"
|
||||
RIBS_CRV = "Rib"
|
||||
|
||||
SHELL_NBR_GRP = "ShellNbrRegions"
|
||||
SHELL_NBR_CRV = "ShellNbrRegion"
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return AddManData
|
||||
|
||||
+521
-124
@@ -14,6 +14,7 @@ local AMD = require( 'AddManData')
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local s_nPartId
|
||||
local s_dOffsCorr = 50 * GEO.EPS_SMALL
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetLayerParamsForPathCalc()
|
||||
@@ -28,6 +29,21 @@ local function GetLayerParamsForPathCalc()
|
||||
return LayerParams
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------
|
||||
local function ComputeSurfOffset( nSrf, nGrpId, dOffs)
|
||||
|
||||
local nCopySrf = EgtCopy( nSrf, nGrpId)
|
||||
local bOk = EgtSurfFrOffset( nCopySrf, dOffs)
|
||||
local bExists = EgtSurfFrChunkCount( nCopySrf) > 0
|
||||
if not bOk or not bExists then
|
||||
EgtErase( nCopySrf)
|
||||
nCopySrf = EgtCopyGlob( nSrf, nGrpId)
|
||||
bOk = EgtSurfFrOffset( nCopySrf, dOffs + 0.05)
|
||||
bExists = EgtSurfFrChunkCount( nCopySrf) > 0
|
||||
end
|
||||
return bOk, bExists, nCopySrf
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetLayerStartPoint( nLayId, vtSlicing)
|
||||
|
||||
@@ -65,19 +81,25 @@ local function GetLayerStartPoint( nLayId, vtSlicing)
|
||||
return vPtStart
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------
|
||||
local function ComputeSurfOffset( nSrf, nGrpId, dOffs)
|
||||
---------------------------------------------------------------------
|
||||
local function ModifyStartPoint( nCrvId, vPtStart)
|
||||
|
||||
local nCopySrf = EgtCopy( nSrf, nGrpId)
|
||||
local bOk = EgtSurfFrOffset( nCopySrf, dOffs)
|
||||
local bExists = EgtSurfFrChunkCount( nCopySrf) > 0
|
||||
if not bOk or not bExists then
|
||||
EgtErase( nCopySrf)
|
||||
nCopySrf = EgtCopyGlob( nSrf, nGrpId)
|
||||
bOk = EgtSurfFrOffset( nCopySrf, dOffs + 0.05)
|
||||
bExists = EgtSurfFrChunkCount( nCopySrf) > 0
|
||||
-- cerco lo start point più vicino tra quelli possibili
|
||||
if vPtStart and #vPtStart > 0 then
|
||||
local nMinIdx = -1
|
||||
local dMinDist = GEO.INFINITO
|
||||
for i = 1, #vPtStart do
|
||||
local dDist = EgtPointCurveDist( vPtStart[i], nCrvId)
|
||||
if dDist < dMinDist - 10 * GEO.EPS_SMALL then
|
||||
dMinDist = dDist
|
||||
nMinIdx = i
|
||||
end
|
||||
end
|
||||
EgtChangeClosedCurveStartPoint( nCrvId, vPtStart[nMinIdx])
|
||||
else
|
||||
-- se non ci sono start point disponibili prendo l'origine
|
||||
EgtChangeClosedCurveStartPoint( nCrvId, Point3d( 0, 0, 0), GDB_RT.GLOB)
|
||||
end
|
||||
return bOk, bExists, nCopySrf
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -94,32 +116,17 @@ local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, vPtStart)
|
||||
-- se è loop interno lo inverto per averlo orientato in senso antiorario
|
||||
if nInd > 0 then
|
||||
EgtInvertCurve( nCrvId + nInd)
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico soddisfi i requisiti (lunghezza e area)
|
||||
local dLen = EgtCurveLength( nCrvId + nInd)
|
||||
local _ , _ , dArea = EgtCurveArea( nCrvId + nInd)
|
||||
local _ , _ , dArea = EgtCurveArea( nCrvId + nInd)
|
||||
if dLen < MIN_LEN or dArea < MIN_AREA then
|
||||
EgtErase( nCrvId + nInd)
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
-- cerco lo start point più vicino tra quelli possibili
|
||||
if vPtStart and #vPtStart > 0 then
|
||||
local nMinIdx = -1
|
||||
local dMinDist = GEO.INFINITO
|
||||
for i = 1, #vPtStart do
|
||||
local dDist = EgtPointCurveDist( vPtStart[i], nCrvId + nInd)
|
||||
if dDist < dMinDist - 10 * GEO.EPS_SMALL then
|
||||
dMinDist = dDist
|
||||
nMinIdx = i
|
||||
end
|
||||
end
|
||||
EgtChangeClosedCurveStartPoint( nCrvId + nInd, vPtStart[nMinIdx])
|
||||
else
|
||||
-- se non ci sono start point disponibili prendo l'origine
|
||||
EgtChangeClosedCurveStartPoint( nCrvId + nInd, Point3d( 0, 0, 0), GDB_RT.GLOB)
|
||||
end
|
||||
ModifyStartPoint( nCrvId + nInd, vPtStart)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -147,6 +154,10 @@ local function AddFloor( nSrfId, nGrpId, LayerParams, nFloorNbr)
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
--------------------------- RIBS -----------------------------------
|
||||
--------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function TrimRibsOffset( nCrv, nOffs1, nOffs2, nOffsGrp, bIn)
|
||||
|
||||
@@ -310,41 +321,17 @@ local function HandleRibsIntersections( nRibsGrp, LayerParams, nOffsGrp, nRibsPa
|
||||
|
||||
EgtErase( nTrimmedRibsGrp)
|
||||
|
||||
-- nel caso di intersezione sistemo i nomi in modo da gestire separatamente le costolature divise
|
||||
if bInters then
|
||||
local vRibsNames = {}
|
||||
for i = 1, #vOrigRibs do
|
||||
local sName = EgtGetName( vOrigRibs[i])
|
||||
table.insert( vRibsNames, sName)
|
||||
end
|
||||
local kMax = tonumber( string.sub( vRibsNames[#vRibsNames], 4)) + 1
|
||||
|
||||
for i = 1, #vRibsNames do
|
||||
local vIds = EgtGetNameInGroup( nRibsPathGrp, vRibsNames[i])
|
||||
for j = 2, #vIds do
|
||||
local ptM = EgtMP( vIds[j])
|
||||
local dDist = EgtPointCurveDist( ptM, vIds[j-1])
|
||||
if abs( dDist - LayerParams.dStrand) < 10 * GEO.EPS_SMALL then
|
||||
-- se le costolatura è vicina alla precedente avrà lo stesso nome
|
||||
EgtSetName( vIds[j], EgtGetName( vIds[j-1]))
|
||||
else
|
||||
-- se la costolatura dista troppo dalla precedente le cambio il nome
|
||||
EgtSetName( vIds[j], RIBS_CRV .. tostring( kMax))
|
||||
kMax = kMax + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return bInters
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- Funzione che riordina le costolature nel caso generico
|
||||
local function ReorderRibs( nGrp, bInvertOrder)
|
||||
local function ReorderRibs( nGrp, bInvertOrder, dStrand, nMaxNbr)
|
||||
|
||||
EgtSpInit()
|
||||
local vIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. '*')
|
||||
if not vIds or #vIds == 0 then return end
|
||||
|
||||
local vSplitRibs = {}
|
||||
local vSPRibs = {}
|
||||
for i = 1, #vIds do
|
||||
@@ -374,6 +361,25 @@ local function ReorderRibs( nGrp, bInvertOrder)
|
||||
EgtRelocateGlob( vSplitRibs[i], nPrevId, GDB_IN.AFTER)
|
||||
end
|
||||
|
||||
-- sistemo nomi
|
||||
local kMax = nMaxNbr + 1
|
||||
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 - 10) < 10 * GEO.EPS_SMALL 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)
|
||||
else
|
||||
-- se la costolatura dista troppo dalla precedente le cambio il nome
|
||||
EgtSetName( vIds[j], RIBS_CRV .. tostring( kMax))
|
||||
kMax = kMax + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
@@ -439,7 +445,7 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
end
|
||||
|
||||
-- concateno le curve
|
||||
local nCrv, nCnt = EgtCurveCompoByChain( nOffsGrp, vOffs, ORIG())
|
||||
local nCrv, nCnt = EgtCurveCompoByChain( nOffsGrp, vOffs, ORIG())
|
||||
|
||||
local vIds = {}
|
||||
for i = nCrv, nCrv + nCnt - 1 do
|
||||
@@ -455,27 +461,70 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
table.remove( vIds, 1)
|
||||
EgtSetName( nCurrCrv, RIBS_CRV .. tostring(k))
|
||||
local pt = EgtEP( nCurrCrv)
|
||||
local _, dParE = EgtCurveDomain( nCurrCrv)
|
||||
local nCnt = 0
|
||||
-- scorro alla ricerca di una curva che posso collegare alla corrente
|
||||
while nCurrCrv do
|
||||
local bFound = false
|
||||
for j = 1, #vIds do
|
||||
if vIds[j] ~= nCrv then
|
||||
local ptS = EgtSP( vIds[j])
|
||||
local ptE = EgtEP( vIds[j])
|
||||
if vIds[j] ~= nCrv and not EgtCurveIsClosed(vIds[j]) then
|
||||
|
||||
local bAddNoInvert = dist( pt, ptS) < dStrand + 10 * GEO.EPS_SMALL
|
||||
local bAddWithInvert = dist( pt, ptE) < dStrand + 10 * GEO.EPS_SMALL
|
||||
if bAddNoInvert or bAddWithInvert then
|
||||
-- verifico se il collegamento è possibile
|
||||
local bAdd = false
|
||||
local bInvert = false
|
||||
local dDist, _, dParMinDist = EgtPointCurveDist( pt, vIds[j])
|
||||
if dDist < dStrand + 10 * GEO.EPS_SMALL then
|
||||
-- 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
|
||||
elseif abs( dParMinDist - dParE) < 500 * GEO.EPS_SMALL then
|
||||
bAdd = true
|
||||
-- è se necessaria inversione di vIds[j]
|
||||
bInvert = true
|
||||
end
|
||||
end
|
||||
|
||||
if not bAdd then
|
||||
-- check sullo start point di vIds[j]
|
||||
local dDist, _, dParMinDist = EgtPointCurveDist( EgtSP( vIds[j]), nCurrCrv)
|
||||
if dDist < dStrand + 10 * GEO.EPS_SMALL then
|
||||
bInvert = false
|
||||
-- controllo sia vicino all'end point della curva corrente
|
||||
if dParE - dParMinDist < 500 * GEO.EPS_SMALL then
|
||||
bAdd = true
|
||||
-- altrimenti può essere vicino allo start
|
||||
elseif dParMinDist < 500 * GEO.EPS_SMALL and nCnt == 0 then
|
||||
bAdd = true
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
end
|
||||
end
|
||||
-- se non è aggiunto check con end point di vIds[j]
|
||||
if not bAdd then
|
||||
local dDist, _, dParMinDist = EgtPointCurveDist( EgtEP( vIds[j]), nCurrCrv)
|
||||
if dDist < dStrand + 10 * GEO.EPS_SMALL then
|
||||
bInvert = true
|
||||
if dParE - dParMinDist < 500 * GEO.EPS_SMALL then
|
||||
bAdd = true
|
||||
elseif dParMinDist < 500 * GEO.EPS_SMALL and nCnt == 0 then
|
||||
bAdd = true
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if bAdd then
|
||||
bFound = true
|
||||
nCnt = nCnt + 1
|
||||
EgtRelocateGlob( vIds[j], nCurrCrv, GDB_IN.AFTER)
|
||||
EgtSetName( vIds[j], RIBS_CRV .. tostring( k))
|
||||
-- eventuale inversione della curva
|
||||
if bAddWithInvert then EgtInvertCurve( vIds[j]) end
|
||||
if bInvert then EgtInvertCurve( vIds[j]) end
|
||||
|
||||
-- aggiorno per collegamento successivo
|
||||
pt = EgtIf( bAddNoInvert, ptE, ptS)
|
||||
pt = EgtEP( vIds[j])
|
||||
_, dParE = EgtCurveDomain( vIds[j])
|
||||
nCurrCrv = vIds[j]
|
||||
-- elimino la curva dal vettore di curve da considerare
|
||||
table.remove( vIds, j)
|
||||
@@ -485,14 +534,7 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
end
|
||||
-- se non ho più curve da collegare
|
||||
if not bFound then
|
||||
-- se il percorso è fatto da una sola curva, riprovo a cercare collegamenti invertendola
|
||||
if nCnt == 0 then
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
pt = EgtEP( nCurrCrv)
|
||||
nCnt = 1 -- per evitare di finire in un loop
|
||||
else
|
||||
nCurrCrv = nil
|
||||
end
|
||||
nCurrCrv = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -501,8 +543,10 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand)
|
||||
ReassignInfo( nCrv, nCnt, vCopy)
|
||||
end
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, nMaxStrandDiff)
|
||||
|
||||
local vRibs = EgtGetNameInGroup( nRibsGrp, RIBS_CRV .. '*')
|
||||
-- verifico se tutte le costolature vengono fatte con 2 passate
|
||||
@@ -515,8 +559,12 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
end
|
||||
end
|
||||
|
||||
local nLast = EgtGetLastNameInGroup( nRibsGrp, RIBS_CRV .. '*')
|
||||
local sLastName = EgtGetName( nLast)
|
||||
local nMaxNbr = tonumber( string.sub( sLastName, 4))
|
||||
|
||||
-- calcolo gli offset
|
||||
local nOffsGrp = EgtGroup( nRibsGrp)
|
||||
local nOffsGrp = EgtGroup( nRibsGrp)
|
||||
for i = 1, #vRibs do
|
||||
local nShellsNbr = EgtGetInfo( vRibs[i], KEY_RIBS_SHELLS_NBR, 'i')
|
||||
local dOffs = ( nShellsNbr - 1) * LayerParams.dStrand / 2
|
||||
@@ -533,7 +581,7 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
local nCrvGrp = EgtGetFirstNameInGroup( nSliceGrp, CONTOUR_GRP .. '*')
|
||||
while nCrvGrp do
|
||||
|
||||
-- creo o svuoto il gruppo
|
||||
-- creo o svuoto il gruppo
|
||||
local nRibsPathGrp = EgtGetFirstNameInGroup( nCrvGrp, RIBS_GRP)
|
||||
if not nRibsPathGrp then
|
||||
nRibsPathGrp = EgtGroup( nCrvGrp)
|
||||
@@ -544,21 +592,18 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
end
|
||||
|
||||
-- creo le superfici con cui fare i trim
|
||||
local nSrf = EgtGetFirstNameInGroup( nCrvGrp, LAYER_SRF)
|
||||
local bOk, bExists, nSrfBase = ComputeSurfOffset( nSrf, nRibsPathGrp, - dOffs)
|
||||
if not bOk then
|
||||
EgtOutLog( 'Error on Offset for Ribs (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
elseif not bExists then
|
||||
EgtOutLog( 'Warning: Ribs not possibile (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
else
|
||||
local vSurfOffs = {}
|
||||
local nSrfBase = EgtGetFirstNameInGroup( nCrvGrp, TOT_SHELL_TRIM_SURF)
|
||||
if not nSrfBase then
|
||||
EgtOutLog( 'Warning : Ribs not possible (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
else
|
||||
local vSurfOffs = {}
|
||||
for i = 1, #vRibs do
|
||||
local nOverlap = EgtGetInfo( vRibs[i], KEY_RIBS_OVERLAP, 'i')
|
||||
if not vSurfOffs[nOverlap] then
|
||||
local dNewOffs = ( 1 - nOverlap / 100) * LayerParams.dStrand
|
||||
local bOk, bExists, nSrfOffs = ComputeSurfOffset( nSrfBase, nRibsPathGrp, - dNewOffs)
|
||||
if bOk and bExists then
|
||||
vSurfOffs[ nOverlap] = nSrfOffs
|
||||
if not vSurfOffs[nOverlap] then
|
||||
local dNewOffs = nOverlap / 100 * LayerParams.dStrand
|
||||
local bOk, bExists, nSrfOffs = ComputeSurfOffset( nSrfBase, nRibsPathGrp, dNewOffs)
|
||||
if bOk then
|
||||
vSurfOffs[nOverlap] = nSrfOffs
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -566,19 +611,11 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
-- gestisco eventuali intersezioni fra costolature
|
||||
local bInters = HandleRibsIntersections( nRibsGrp, LayerParams, nOffsGrp, nRibsPathGrp, bAllTwoStrands)
|
||||
EgtSetInfo( nRibsPathGrp or GDB_ID.NULL, KEY_RIBS_INTERS, bInters)
|
||||
EgtSetInfo( nRibsPathGrp or GDB_ID.NULL, KEY_RIBS_TWO_STRANDS, bAllTwoStrands)
|
||||
|
||||
-- riordino le costolature
|
||||
if bAllTwoStrands and bInters then
|
||||
-- gestione caso speciale di intersezione e 2 passate
|
||||
ReorderRibsInters2Shells( nRibsPathGrp, LayerParams.dStrand)
|
||||
else
|
||||
ReorderRibs( nRibsPathGrp, LayerParams.bRibsInvertOrder)
|
||||
end
|
||||
|
||||
EgtSetInfo( nRibsPathGrp or GDB_ID.NULL, KEY_RIBS_TWO_STRANDS, bAllTwoStrands)
|
||||
|
||||
-- eseguo il trim delle costole con la regione offsettata
|
||||
local vErased = {}
|
||||
local vOrderedRibs = EgtGetNameInGroup( nRibsPathGrp, RIBS_CRV .. '*')
|
||||
local tOldNewIds = {}
|
||||
local vOrderedRibs = EgtGetNameInGroup( nRibsPathGrp, RIBS_CRV ..'*')
|
||||
for i = 1, #vOrderedRibs do
|
||||
-- trim con superficie opportuna
|
||||
local nOverlap = EgtGetInfo( vOrderedRibs[i], KEY_RIBS_OVERLAP, 'i')
|
||||
@@ -586,33 +623,48 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
-- la costolatura non è fattibile
|
||||
EgtOutLog( 'Warning: Ribs not possibile (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
EgtErase( vOrderedRibs[i])
|
||||
vErased[vOrderedRibs[i]] = 1
|
||||
else
|
||||
local nCrv, nCnt = EgtTrimCurveWithRegion( vOrderedRibs[i], vSurfOffs[nOverlap], true, false)
|
||||
if nCnt == 0 then
|
||||
-- lo aggiungo nella tabella delle costolature eliminate
|
||||
vErased[vOrderedRibs[i]] = 1
|
||||
end
|
||||
tOldNewIds[ vOrderedRibs[i]] = {}
|
||||
|
||||
-- elimino tratti troppo corti
|
||||
for nId = nCrv, nCrv + nCnt - 1 do
|
||||
local dLen = EgtCurveLength( nId)
|
||||
for nInd = 0, nCnt - 1 do
|
||||
local dLen = EgtCurveLength( nCrv + nInd)
|
||||
if dLen < 10 * MIN_LEN then
|
||||
EgtErase( nId)
|
||||
-- lo aggiungo nella tabella delle costolature eliminate
|
||||
vErased[vOrderedRibs[i]] = 1
|
||||
EgtErase( nCrv + nInd)
|
||||
else
|
||||
local nInfo = EgtGetInfo( nId, KEY_SPLIT_RIB, 'i')
|
||||
-- se la costolatura da cui deriva è stata eliminata, tolgo l'info che le associava
|
||||
if nInfo and vErased[nInfo] then
|
||||
EgtRemoveInfo( nId, KEY_SPLIT_RIB)
|
||||
table.insert( tOldNewIds[ vOrderedRibs[i]], nCrv + nInd)
|
||||
if nInd > 0 then
|
||||
-- info split
|
||||
EgtSetInfo( nCrv + nInd, KEY_SPLIT_RIB, nCrv + nInd - 1)
|
||||
else
|
||||
-- aggiorno la info
|
||||
local nInfo = EgtGetInfo( nCrv + nInd, KEY_SPLIT_RIB, 'i')
|
||||
if nInfo then
|
||||
-- aggiorno info
|
||||
if #tOldNewIds[nInfo] > 0 then
|
||||
local nLast = #tOldNewIds[nInfo]
|
||||
EgtSetInfo( nCrv + nInd, KEY_SPLIT_RIB, tOldNewIds[nInfo][nLast])
|
||||
else
|
||||
-- se la costolatura da cui deriva è stata eliminata, tolgo l'info che le associava
|
||||
EgtRemoveInfo( nCrv + nInd, KEY_SPLIT_RIB)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- riordino le costolature
|
||||
if bAllTwoStrands and bInters then
|
||||
-- gestione caso speciale di intersezione e 2 passate
|
||||
ReorderRibsInters2Shells( nRibsPathGrp, LayerParams.dStrand)
|
||||
else
|
||||
ReorderRibs( nRibsPathGrp, LayerParams.bRibsInvertOrder, LayerParams.dStrand, nMaxNbr)
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nSrfBase)
|
||||
if not EgtGetFirstNameInGroup( nRibsPathGrp, RIBS_CRV .. '*') then
|
||||
EgtErase( nRibsPathGrp)
|
||||
end
|
||||
@@ -620,8 +672,333 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
----------------- REGIONI CON DIVERSE PASSATE ----------------------
|
||||
--------------------------------------------------------------------
|
||||
local function CreateShellNbrSurfaces( nGrp, nShellsNbr)
|
||||
|
||||
if not nGrp then return end
|
||||
|
||||
local tDiffCrvs = {}
|
||||
local nMaxShellNbrDiff = 0
|
||||
local nCrvId = EgtGetFirstNameInGroup( nGrp, SHELL_NBR_CRV .. '*')
|
||||
while nCrvId do
|
||||
-- recupero info sul gap
|
||||
local nShellNbrDiff = EgtGetInfo( nCrvId, KEY_SHELL_NBR_DIFF, 'i')
|
||||
-- aggiorno eventuale massimo
|
||||
if nMaxShellNbrDiff < nShellNbrDiff then nMaxShellNbrDiff = nShellNbrDiff end
|
||||
-- salvo gli id delle curve
|
||||
if not tDiffCrvs[nShellNbrDiff] then
|
||||
tDiffCrvs[nShellNbrDiff] = { nCrvId}
|
||||
else
|
||||
table.insert( tDiffCrvs[nShellNbrDiff], nCrvId)
|
||||
end
|
||||
|
||||
nCrvId = EgtGetNextName( nCrvId, SHELL_NBR_CRV .. '*')
|
||||
end
|
||||
|
||||
-- eventuale correzione del numero massimo in base al numero di pareti interne
|
||||
nMaxShellNbrDiff = min( nMaxShellNbrDiff, nShellsNbr - 1)
|
||||
|
||||
-- costruisco per ogni valore la superficie complessiva
|
||||
local nSrfGrp = EgtGroup( nGrp)
|
||||
for nDiff = 1, nMaxShellNbrDiff do
|
||||
-- recupero gli id delle curve coinvolte
|
||||
local vCrvIds = {}
|
||||
for nG, vIds in pairs( tDiffCrvs) do
|
||||
if nG >= nDiff then
|
||||
for k = 1, #vIds do
|
||||
table.insert( vCrvIds, vIds[k])
|
||||
end
|
||||
end
|
||||
end
|
||||
-- costruisco la surf
|
||||
local nSrfId, nCnt = EgtSurfFlatRegion( nSrfGrp, vCrvIds)
|
||||
for nIdSrf = nSrfId + 1, nSrfId + nCnt - 2 do
|
||||
EgtSurfFrAdd( nSrfId, nIdSrf)
|
||||
end
|
||||
EgtSetName( nSrfId, SHELL_NBR_SURF .. tostring( nDiff))
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeMaxShellNbrDiff( nSrf, nShellNbrSurfGrp)
|
||||
|
||||
local nMaxShellNbrDiff = 0
|
||||
if nShellNbrSurfGrp then
|
||||
local nId = 1
|
||||
local nShellNbrSrf = EgtGetFirstNameInGroup( nShellNbrSurfGrp, SHELL_NBR_SURF .. tostring( nId))
|
||||
while nShellNbrSrf do
|
||||
-- se interessa la regione considerata aggiorno il nMaxShellNbrDiff
|
||||
if not EgtSurfFrTestExternal( nSrf, nShellNbrSrf) then
|
||||
nMaxShellNbrDiff = nId
|
||||
end
|
||||
|
||||
-- passo al successivo
|
||||
nId = nId + 1
|
||||
nShellNbrSrf = EgtGetFirstNameInGroup( nShellNbrSurfGrp, SHELL_NBR_SURF .. tostring( nId))
|
||||
end
|
||||
end
|
||||
|
||||
return nMaxShellNbrDiff
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function UpdateTotalShellSurf( nSrf, nCrv, dStrand, nGrpId)
|
||||
|
||||
local nCopyCrv = EgtCopyGlob( nCrv, nGrpId)
|
||||
-- creo percorso chiuso corrispondente
|
||||
if not EgtCurveIsClosed( nCrv) then
|
||||
local nCopy2 = EgtCopyGlob( nCrv, nGrpId)
|
||||
EgtInvertCurve( nCopy2)
|
||||
EgtAddCurveCompoCurve( nCopyCrv, nCopy2)
|
||||
end
|
||||
|
||||
local nOffsP = EgtOffsetCurveAdv( nCopyCrv, dStrand - s_dOffsCorr, GDB_OT.EXTEND)
|
||||
local vSrfIds = { nOffsP}
|
||||
if EgtCurveIsClosed( nCrv) then
|
||||
-- se curva è chiusa bisogna tenere conto dell'interno
|
||||
local nOffsM, nCnt = EgtOffsetCurveAdv( nCopyCrv, - dStrand + s_dOffsCorr)
|
||||
if nOffsM and nOffsM ~= GDB_ID.NULL then
|
||||
for nId = nOffsM, nOffsM + nCnt - 1 do
|
||||
table.insert( vSrfIds, nId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local nSrfExtraShell = EgtSurfFlatRegion( nGrpId, vSrfIds)
|
||||
if not EgtSurfFrSubtract( nSrf, nSrfExtraShell) then
|
||||
EgtInvertSurf( nSrfExtraShell)
|
||||
EgtSurfFrSubtract( nSrf, nSrfExtraShell)
|
||||
end
|
||||
|
||||
EgtErase( nCopyCrv)
|
||||
for i = 1, #vSrfIds do
|
||||
EgtErase( vSrfIds[i])
|
||||
end
|
||||
EgtErase( nSrfExtraShell)
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function CalcPaths.Exec( nPartId, nStmId)
|
||||
local function JoinAndReorderExtraShells( nPathGrp, dStrand, vPtStart)
|
||||
|
||||
local vIds = EgtGetNameInGroup( nPathGrp, EXTRA_SHELL_CRV .. '*')
|
||||
if not vIds then return end
|
||||
|
||||
-- cerco di creare percorsi
|
||||
local k = 0 -- indice da utilizzare per i nomi
|
||||
while #vIds > 0 do
|
||||
k = k + 1
|
||||
-- prendo la prima tra le curve a disposizione
|
||||
nCurrCrv = vIds[1]
|
||||
table.remove( vIds, 1)
|
||||
EgtSetName( nCurrCrv, EXTRA_SHELL_CRV .. tostring(k))
|
||||
local ptSCurr = EgtSP( nCurrCrv)
|
||||
local ptECurr = EgtEP( nCurrCrv)
|
||||
local nCnt = 0
|
||||
-- se curva è chiusa
|
||||
if EgtCurveIsClosed( nCurrCrv) then
|
||||
ModifyStartPoint( nCurrCrv, vPtStart)
|
||||
EgtSetInfo( nCurrCrv, KEY_CLOSED_EXTRA_SHELL, 1)
|
||||
-- setto a nil per ripartire subito con curva successiva
|
||||
nCurrCrv = nil
|
||||
end
|
||||
|
||||
-- scorro alla ricerca di una curva che posso collegare alla corrente
|
||||
while nCurrCrv do
|
||||
local bFound = false
|
||||
for j = 1, #vIds do
|
||||
|
||||
if not EgtCurveIsClosed( vIds[j]) then
|
||||
local ptS = EgtSP( vIds[j])
|
||||
local ptE = EgtEP( vIds[j])
|
||||
|
||||
if nCnt == 0 and dist( ptE, ptSCurr) < 1.5 * dStrand and EgtGetName( nCurrCrv) == EgtGetName( vIds[j]) then
|
||||
nCnt = nCnt + 1
|
||||
EgtRelocateGlob( vIds[j], nCurrCrv, GDB_IN.BEFORE)
|
||||
EgtSetName( vIds[j], EXTRA_SHELL_CRV .. tostring( k))
|
||||
table.remove( vIds, j)
|
||||
bFound = true
|
||||
break
|
||||
end
|
||||
|
||||
local bLink = dist( ptS, ptECurr) < 1.5 * dStrand
|
||||
|
||||
if dist( ptE, ptECurr) < 1.5 * dStrand then
|
||||
-- congiungo end-end
|
||||
EgtInvertCurve( vIds[j])
|
||||
EgtSetInfo( vIds[j], KEY_INVERTED_CURVE, 1)
|
||||
bLink = true
|
||||
elseif nCnt == 0 and dist( ptS, ptSCurr) < 1.5 * dStrand then
|
||||
-- congiungo start-start
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
EgtSetInfo( nCurrCrv, KEY_INVERTED_CURVE, 1)
|
||||
bLink = true
|
||||
end
|
||||
|
||||
if bLink then
|
||||
nCnt = nCnt + 1
|
||||
EgtRelocateGlob( vIds[j], nCurrCrv, GDB_IN.AFTER)
|
||||
EgtSetName( vIds[j], EXTRA_SHELL_CRV .. tostring( k))
|
||||
|
||||
-- aggiorno per collegamento successivo
|
||||
bFound = true
|
||||
nCurrCrv = vIds[j]
|
||||
ptSCurr = EgtSP( vIds[j])
|
||||
ptECurr = EgtEP( vIds[j])
|
||||
table.remove( vIds, j)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se non ho più curve da collegare
|
||||
if not bFound then
|
||||
nCurrCrv = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se posso realizzare percorsi chiusi
|
||||
for i = 1, k do
|
||||
local vIds = EgtGetNameInGroup( nPathGrp, EXTRA_SHELL_CRV .. tostring(i))
|
||||
if #vIds == 2 then
|
||||
local ptS = EgtSP( vIds[1])
|
||||
local ptE = EgtEP( vIds[2])
|
||||
if dist( ptS, ptE) < 1.5 * dStrand then
|
||||
EgtAddCurveCompoLine( vIds[1], EgtSP( vIds[2]))
|
||||
EgtAddCurveCompoCurve( vIds[1], vIds[2])
|
||||
EgtCloseCurveCompo( vIds[1])
|
||||
-- modifico lo start point
|
||||
ModifyStartPoint( vIds[1], vPtStart)
|
||||
-- ripristino se necessario orientamento antiorario
|
||||
if EgtGetInfo( vIds[1], KEY_INVERTED_CURVE, 'b') then
|
||||
EgtInvertCurve( vIds[1])
|
||||
EgtSetInfo( vIds[1], KEY_INVERTED_CURVE, 0)
|
||||
end
|
||||
EgtSetInfo( vIds[1], KEY_CLOSED_EXTRA_SHELL, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyExtraShellPath( nCrv, nGrpId, vtSlicing, dStrand)
|
||||
|
||||
-- verifico se è fattibile controllando se esiste offset
|
||||
local nOffs, nCnt = EgtOffsetCurveAdv( nCrv, - 0.5 * dStrand)
|
||||
if not nOffs or nOffs == GDB_ID.NULL then
|
||||
return false
|
||||
end
|
||||
for i = nOffs, nOffs + nCnt - 1 do
|
||||
EgtErase( i)
|
||||
end
|
||||
|
||||
-- controllo se è fattibile con una sola passata
|
||||
if EgtCurveIsClosed( nCrv) then
|
||||
local nGrpTmp = EgtGroup( nGrpId, Frame3d( ORIG(), vtSlicing))
|
||||
EgtRelocateGlob( nCrv, nGrpTmp)
|
||||
local dArea = EgtCurveAreaXY( nCrv)
|
||||
if dArea < 10 * GEO.EPS_SMALL then
|
||||
-- TODO curva generica
|
||||
local frLoc, dDimX, dDimY = EgtCurveMinAreaRectangleXY( nCrv)
|
||||
if dDimY < 10 * GEO.EPS_SMALL then
|
||||
local dZ = EgtSP( nCrv):getZ()
|
||||
-- creo la curva che corrisponde alla sigola passata
|
||||
local ptS = frLoc:getOrigin() - dDimX / 2 * frLoc:getVersX() + dZ * Z_AX()
|
||||
local ptE = frLoc:getOrigin() + dDimX / 2 * frLoc:getVersX() + dZ * Z_AX()
|
||||
if dist( ptS, ptE) > 5 then
|
||||
local nId = EgtCurveCompoFromPoints( nGrpTmp, { ptS, ptE})
|
||||
EgtErase( nCrv)
|
||||
EgtChangeId( nId, nCrv)
|
||||
end
|
||||
end
|
||||
end
|
||||
EgtRelocateGlob( nCrv, nGrpId, GDB_IN.LAST_SON)
|
||||
EgtErase( nGrpTmp)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcExtraShellsPath( nMaxShellNbrDiff, nShellNbrGrp, nCrvGrpId, dOffs, LayerParams, nIdx, vPtStart)
|
||||
|
||||
local nGrpId = EgtGetFirstNameInGroup( nCrvGrpId, PATH_GRP)
|
||||
|
||||
-- recupero la superficie occupata dalle shell per trim
|
||||
local nSrfTrim = EgtGetFirstNameInGroup( nCrvGrpId, TOT_SHELL_TRIM_SURF)
|
||||
if not nSrfTrim then
|
||||
EgtOutLog( 'Warning : ExtraInnerShells not possible (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
return
|
||||
end
|
||||
|
||||
for nInd = nMaxShellNbrDiff, 1, -1 do
|
||||
dOffs = dOffs + LayerParams.dStrand
|
||||
local nSrfDiff = EgtGetFirstNameInGroup( nShellNbrGrp, SHELL_NBR_SURF .. tostring( nInd))
|
||||
local nOuterCrv = EgtGetFirstNameInGroup( nCrvGrpId, OUTER_CRV)
|
||||
while nOuterCrv do
|
||||
local nCopy = EgtCopyGlob( nOuterCrv, nGrpId)
|
||||
|
||||
-- trim della curva con la regione con diverso numero di passate
|
||||
local nTrimCrv, nTrimCnt = EgtTrimCurveWithRegion( nCopy, nSrfDiff, false, false)
|
||||
if nTrimCnt ~= 0 then
|
||||
-- verifico se prima e ultima curva possono essere unite
|
||||
if nTrimCnt > 1 and AreSamePointApprox( EgtEP( nTrimCrv + nTrimCnt - 1), EgtSP( nTrimCrv)) then
|
||||
local nNewId = EgtCurveCompo( nGrpId, { nTrimCrv + nTrimCnt - 1, nTrimCrv})
|
||||
EgtChangeId( nNewId, nTrimCrv)
|
||||
nTrimCnt = nTrimCnt - 1
|
||||
end
|
||||
|
||||
for nCrvT = nTrimCrv, nTrimCrv + nTrimCnt - 1 do
|
||||
-- calcolo offset della curva ( è il percorso della shell)
|
||||
EgtModifyCurveExtrusion( nCrvT, LayerParams.vtSlicing)
|
||||
local nOffs, nOffsCnt = EgtOffsetCurveAdv( nCrvT, - dOffs)
|
||||
EgtErase( nCrvT)
|
||||
for nCrvOffs = nOffs, nOffs + nOffsCnt - 1 do
|
||||
-- trim con la regione già occupata dal altre shell
|
||||
local nCrv, nCnt = EgtTrimCurveWithRegion( nCrvOffs, nSrfTrim, true, true)
|
||||
if nCrv and nCnt ~= 0 then
|
||||
for nId = nCrv, nCrv + nCnt - 1 do
|
||||
local dLen = EgtCurveLength( nId)
|
||||
local bValid = VerifyExtraShellPath( nId, nGrpId, LayerParams.vtSlicing, LayerParams.dStrand)
|
||||
-- verifico se soddisfa vincolo sulla lunghezza
|
||||
if dLen > MIN_LEN and bValid then
|
||||
EgtModifyCurveExtrusion( nId, LayerParams.vtSlicing)
|
||||
EgtSetName( nId, EXTRA_SHELL_CRV .. tostring( nMaxShellNbrDiff - nInd + 1))
|
||||
EgtSetInfo( nId, KEY_TYPE, TYPE.EXTRA_SHELL)
|
||||
-- aggiorno la superficie occupata dalle shell con quella appena calcolata
|
||||
UpdateTotalShellSurf( nSrfTrim, nId, LayerParams.dStrand, nGrpId)
|
||||
-- se la superficie si annulla non è possibile realizzare altro, quindi cancello tutte le curve rimaste
|
||||
if EgtSurfFrChunkCount( nSrfTrim) == 0 then
|
||||
for j = nId + 1, nCrv + nCnt - 1 do
|
||||
EgtErase( j)
|
||||
end
|
||||
for j = nCrvT + 1, nTrimCrv + nTrimCnt - 1 do
|
||||
EgtErase( j)
|
||||
end
|
||||
JoinAndReorderExtraShells( nGrpId, LayerParams.dStrand, vPtStart)
|
||||
return
|
||||
end
|
||||
else
|
||||
EgtErase( nId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
nOuterCrv = EgtGetNextName( nOuterCrv, OUTER_CRV)
|
||||
end
|
||||
end
|
||||
|
||||
-- riordino le curve appena create e se possibile creo percorsi chiusi
|
||||
JoinAndReorderExtraShells( nGrpId, LayerParams.dStrand, vPtStart)
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function CalcPaths.Exec( nPartId)
|
||||
|
||||
s_nPartId = nPartId
|
||||
|
||||
@@ -637,6 +1014,11 @@ function CalcPaths.Exec( nPartId, nStmId)
|
||||
for nIdx = 1, #vLayIds do
|
||||
|
||||
local nRibsGrp = EgtGetFirstNameInGroup( vLayIds[nIdx], RIBS_GRP)
|
||||
|
||||
-- regioni con diverso numero di passate
|
||||
local nShellNbrGrp = EgtGetFirstNameInGroup( vLayIds[nIdx], SHELL_NBR_GRP)
|
||||
CreateShellNbrSurfaces( nShellNbrGrp, LayerParams.nShellsNbr)
|
||||
local nShellNbrSurfGrp = EgtGetFirstGroupInGroup( nShellNbrGrp or GDB_ID.NULL)
|
||||
|
||||
-- recupero gli start point per il layer
|
||||
local vPtStart = GetLayerStartPoint( vLayIds[nIdx], LayerParams.vtSlicing)
|
||||
@@ -676,21 +1058,37 @@ function CalcPaths.Exec( nPartId, nStmId)
|
||||
end
|
||||
EgtErase( nSrfId)
|
||||
|
||||
-- pareti interne
|
||||
for nInd2 = 1, LayerParams.nShellsNbr - 1 do
|
||||
-- pareti interne complete
|
||||
local nMaxShellNbrDiff = ComputeMaxShellNbrDiff( nSrf, nShellNbrSurfGrp)
|
||||
for nInd = 1, LayerParams.nShellsNbr - 1 - nMaxShellNbrDiff do
|
||||
-- offset della superficie originale
|
||||
local bOk, bExists, nSrfId = ComputeSurfOffset( nSrf, nCrvGrpId, - dOffs - nInd2 * LayerParams.dStrand)
|
||||
dOffs = dOffs + LayerParams.dStrand
|
||||
local bOk, bExists, nSrfId = ComputeSurfOffset( nSrf, nCrvGrpId, - dOffs)
|
||||
if not bOk then
|
||||
EgtOutLog( 'Error on IntOffset (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
elseif not bExists then
|
||||
EgtOutLog( 'Warning : IntOffset not possible (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
else
|
||||
-- se offset riuscito, estraggo i contorni ( pareti interne)
|
||||
GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, vPtStart)
|
||||
GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd), TYPE.INNER_SHELL, nGrpId, vPtStart)
|
||||
end
|
||||
EgtErase( nSrfId)
|
||||
end
|
||||
|
||||
-- preparo superficie occupata dalle shell da usare per trim
|
||||
local bOkTrim, bExistsTrim, nSrfTrim = ComputeSurfOffset( nSrf, nCrvGrpId, - dOffs - LayerParams.dStrand + s_dOffsCorr)
|
||||
if not bOkTrim then
|
||||
EgtOutLog( 'Error on IntOffset (layer '..tostring( nIdx)..') - CalcPaths')
|
||||
elseif bExistsTrim then
|
||||
EgtSetName( nSrfTrim, TOT_SHELL_TRIM_SURF)
|
||||
EgtSetStatus( nSrfTrim, GDB_ST.OFF)
|
||||
end
|
||||
|
||||
-- eventuali pareti interne coinvolte dal diverso numero di passate
|
||||
if nMaxShellNbrDiff > 0 then
|
||||
CalcExtraShellsPath( nMaxShellNbrDiff, nShellNbrSurfGrp, nCrvGrpId, dOffs, LayerParams, nIdx, vPtStart)
|
||||
end
|
||||
|
||||
-- gestione eventuale floor
|
||||
if nIdx <= LayerParams.nFloorNbr then
|
||||
AddFloor( nSrf, nGrpId, LayerParams, nIdx)
|
||||
@@ -703,7 +1101,7 @@ function CalcPaths.Exec( nPartId, nStmId)
|
||||
|
||||
-- sistemo eventuali costolature
|
||||
if nRibsGrp then
|
||||
CalcRibsPaths( vLayIds[nIdx], nRibsGrp, LayerParams, nStmId, nIdx)
|
||||
CalcRibsPaths( vLayIds[nIdx], nRibsGrp, LayerParams, nIdx, nMaxStrandDiff)
|
||||
end
|
||||
|
||||
if EgtProcessEvents( nIdx / #vLayIds * 100, 0) == 1 then
|
||||
@@ -713,6 +1111,5 @@ function CalcPaths.Exec( nPartId, nStmId)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return CalcPaths
|
||||
|
||||
+58
-35
@@ -47,12 +47,30 @@ local function ComputeMaxH( nStmId, frSlicing, HMax)
|
||||
local b3Box = EgtGetBBoxGlob( nGrpTmp, GDB_BB.STANDARD)
|
||||
EgtErase( nGrpTmp)
|
||||
local ptMin = b3Box:getMin()
|
||||
ptMin:toLoc( frSlicing)
|
||||
ptMin:toLoc( frSlicing)
|
||||
return ptMin:getZ()
|
||||
end
|
||||
return GEO.INFINITO
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AdjustRibs( nRibsLay)
|
||||
|
||||
-- recupero le superfici che definiscono le nervature
|
||||
local vRibsIds = EgtGetAllInGroup( nRibsLay or GDB_ID.NULL)
|
||||
if not vRibsIds or #vRibsIds == 0 then return end
|
||||
-- sistemo la direzione normale dei piani
|
||||
for i = 1, #vRibsIds do
|
||||
if EgtGetType( vRibsIds[i]) == GDB_TY.SRF_MESH then
|
||||
local vtN = EgtSurfTmFacetNormVersor( vRibsIds[i], 0)
|
||||
local dVal = EgtIf( abs( vtN:getX()) > abs( vtN:getY()) - GEO.EPS_SMALL, vtN:getX(), vtN:getY())
|
||||
if dVal < - GEO.EPS_SMALL then
|
||||
EgtInvertSurf( vRibsIds[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ReadParam( nId, sKey, sType, table)
|
||||
local info = EgtGetInfo( nId, sKey, sType) or EgtGetInfo( s_nPartId, sKey, sType)
|
||||
@@ -85,32 +103,27 @@ local function GetRibParams( nId)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function SlicingRibs( vtSlicing)
|
||||
|
||||
local nRibsShells = EgtGetInfo( s_nPartId, KEY_RIBS_SHELLS_NBR, 'i') or 0
|
||||
if nRibsShells == 0 then return end
|
||||
local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName)
|
||||
|
||||
-- recupero le superfici che definiscono le nervature
|
||||
local nRibsLay = EgtGetFirstNameInGroup( s_nPartId, LAY_RIBS)
|
||||
local vRibsIds = EgtGetAllInGroup( nRibsLay or GDB_ID.NULL)
|
||||
if not vRibsIds or #vRibsIds == 0 then return end
|
||||
|
||||
-- sistemo la direzione normale dei piani
|
||||
for i = 1, #vRibsIds do
|
||||
if EgtGetType( vRibsIds[i]) == GDB_TY.SRF_MESH then
|
||||
local vtN = EgtSurfTmFacetNormVersor( vRibsIds[i], 0)
|
||||
local dVal = EgtIf( abs( vtN:getX()) > abs( vtN:getY()) - GEO.EPS_SMALL, vtN:getX(), vtN:getY())
|
||||
if dVal < - GEO.EPS_SMALL then
|
||||
EgtInvertSurf( vRibsIds[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- recupero i parametri di ogni costolatura
|
||||
-- recupero gli oggeti di cui fare slicing
|
||||
local vIds = EgtGetAllInGroup( nLay)
|
||||
if not vIds or #vIds == 0 then return end
|
||||
|
||||
-- recupero i parametri di ogni oggetto
|
||||
local tabParams = {}
|
||||
for i = 1, #vRibsIds do
|
||||
local vRibParams = GetRibParams( vRibsIds[i])
|
||||
table.insert( tabParams, vRibParams)
|
||||
local vToBeDone = {}
|
||||
for i = 1, #vIds do
|
||||
local vParams = {}
|
||||
local bToBeDone = true
|
||||
if nType == TYPE.RIB then
|
||||
vParams = GetRibParams( vIds[i])
|
||||
if vParams[ KEY_RIBS_SHELLS_NBR] == 0 then bToBeDone = false end
|
||||
elseif nType == TYPE.EXTRA_SHELL then
|
||||
vParams[KEY_SHELL_NBR_DIFF] = EgtGetInfo( vIds[i], KEY_SHELL_NBR_DIFF, 'i') or EgtGetInfo( s_nPartId, KEY_SHELL_NBR_DIFF, 'i')
|
||||
if vParams[KEY_SHELL_NBR_DIFF] == 0 then bToBeDone = false end
|
||||
end
|
||||
table.insert( tabParams, vParams)
|
||||
table.insert( vToBeDone, bToBeDone)
|
||||
end
|
||||
|
||||
local nLayId = EgtGetFirstNameInGroup( s_nPartId, SLICE_LAYER .. '*')
|
||||
@@ -120,13 +133,13 @@ local function SlicingRibs( vtSlicing)
|
||||
local dDeltaZ = EgtGetInfo( nLayId, KEY_SLICE_DELTAZ, 'd')
|
||||
-- creo gruppo per le costolature
|
||||
local nGrp = EgtGroup( nLayId)
|
||||
EgtSetName( nGrp, RIBS_GRP)
|
||||
EgtSetName( nGrp, sNameGrp)
|
||||
EgtSetStatus( nGrp, GDB_ST.OFF)
|
||||
|
||||
for i = 1, #vRibsIds do
|
||||
if EgtGetType( vRibsIds[i]) == GDB_TY.SRF_MESH then
|
||||
-- slicing costolatura
|
||||
local nNewId, nPntCnt, nCrvCnt, nSrfCnt = EgtPlaneSurfTmInters( ORIG() + ( dZ + dDeltaZ) * vtSlicing, vtSlicing, vRibsIds[i], nGrp, GDB_RT.GLOB, TOLER)
|
||||
for i = 1, #vIds do
|
||||
if EgtGetType( vIds[i]) == GDB_TY.SRF_MESH and vToBeDone[i] then
|
||||
-- slicing oggetto
|
||||
local nNewId, nPntCnt, nCrvCnt, nSrfCnt = EgtPlaneSurfTmInters( ORIG() + ( dZ + dDeltaZ) * vtSlicing, vtSlicing, vIds[i], nGrp, GDB_RT.GLOB, TOLER)
|
||||
if nNewId then
|
||||
-- rimuovo punti
|
||||
for nId = nNewId, nNewId + nPntCnt -1 do
|
||||
@@ -134,7 +147,7 @@ local function SlicingRibs( vtSlicing)
|
||||
end
|
||||
-- rinomino le curve, correggo di DeltaZ e assegno parametri
|
||||
for nId = nNewId + nPntCnt, nNewId + nPntCnt + nCrvCnt - 1 do
|
||||
EgtSetName( nId, RIBS_CRV .. tostring( i))
|
||||
EgtSetName( nId, sName .. tostring( i))
|
||||
EgtMove( nId, - dDeltaZ * vtSlicing)
|
||||
for sKey, sVal in pairs( tabParams[i]) do
|
||||
EgtSetInfo( nId, sKey, sVal)
|
||||
@@ -155,7 +168,7 @@ local function SlicingRibs( vtSlicing)
|
||||
nLayId = EgtGetNextName( nLayId, SLICE_LAYER .. '*')
|
||||
end
|
||||
|
||||
return true
|
||||
return true
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -202,8 +215,8 @@ function CalcSlices.Exec( nPartId, nStmId, HMax)
|
||||
local dZmax = b3Box:getMax():getZ()
|
||||
local dMaxH = ComputeMaxH( nStmId, frSlicing, HMax)
|
||||
dZmax = min( dZmax, dMaxH)
|
||||
--dZmin = 227
|
||||
--dZmax = 230
|
||||
-- dZmin = 20
|
||||
-- dZmax = 230
|
||||
|
||||
-- Eseguo slicing
|
||||
local nLayCnt = 1
|
||||
@@ -426,7 +439,17 @@ function CalcSlices.Exec( nPartId, nStmId, HMax)
|
||||
end
|
||||
|
||||
-- costolature
|
||||
SlicingRibs( vtSlicing)
|
||||
local nRibsLay = EgtGetFirstNameInGroup( s_nPartId, LAY_RIBS)
|
||||
if nRibsLay then
|
||||
AdjustRibs( nRibsLay)
|
||||
SlicingExtraObjects( vtSlicing, nRibsLay, TYPE.RIB, RIBS_GRP, RIBS_CRV)
|
||||
end
|
||||
|
||||
-- solidi per regioni con diverso numero di passate
|
||||
local nShellNbrLay = EgtGetFirstNameInGroup( s_nPartId, LAY_SHELL_NBR)
|
||||
if nShellNbrLay then
|
||||
SlicingExtraObjects( vtSlicing, nShellNbrLay, TYPE.EXTRA_SHELL, SHELL_NBR_GRP, SHELL_NBR_CRV)
|
||||
end
|
||||
|
||||
-- eventuale segnalazione errori
|
||||
if #vErr > 0 then
|
||||
|
||||
@@ -124,7 +124,7 @@ local function CreateSolidFromCurve( nCrvId, nSolidGrp, LayerParams)
|
||||
local Color = EgtStdColor( 'GRAY')
|
||||
if nType == TYPE.OUTER_SHELL then
|
||||
Color = EgtStdColor( 'TEAL')
|
||||
elseif nType == TYPE.INNER_SHELL then
|
||||
elseif nType == TYPE.INNER_SHELL or nType == TYPE.EXTRA_SHELL then
|
||||
Color = EgtStdColor( 'ORANGE')
|
||||
elseif nType == TYPE.LINK then
|
||||
Color = EgtStdColor( 'GRAY')
|
||||
@@ -151,7 +151,7 @@ local function CreateSolidFromCurve( nCrvId, nSolidGrp, LayerParams)
|
||||
local bOk = true
|
||||
for nInd = 0, nParts - 1 do
|
||||
local nGuideId = nId + nInd
|
||||
local nSrfId = CreateSolid( nGuideId, nSolidGrp, LayerParams.dStrand, LayerParams.dLayHeight, LayerParams.vtSlicing)
|
||||
local nSrfId = CreateSolid( nGuideId, nSolidGrp, LayerParams.dStrand - 2 * GEO.EPS_SMALL, LayerParams.dLayHeight, LayerParams.vtSlicing)
|
||||
|
||||
if not nSrfId then
|
||||
-- ritento con sezione leggermente modificata
|
||||
|
||||
+166
-100
@@ -39,7 +39,7 @@ local function GetLayerParamsForToolPathCalc()
|
||||
LayerParams.dTDiam = EgtGetInfo( s_nPartId, KEY_TOOL_DIAM, 'd')
|
||||
-- Parametri costolature
|
||||
LayerParams.bRibsLink = EgtGetInfo( s_nPartId, KEY_RIBS_LINK, 'b')
|
||||
|
||||
|
||||
return LayerParams
|
||||
end
|
||||
|
||||
@@ -57,6 +57,68 @@ local function ComputeZCorrection( LayerParams)
|
||||
return max( dCorr1, dCorr2)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
local function AddLink( vCrv, nTpathGrpId, nLinkType, dLinkParam, dSPOffs, dStrand, vtSlicing)
|
||||
|
||||
if not vCrv or #vCrv == 0 then return end
|
||||
|
||||
local k = 0
|
||||
for i = 2, #vCrv do
|
||||
|
||||
-- link ha senso solo se la curva corrente è chiusa (eviti extra shell aperte)
|
||||
if EgtCurveIsClosed( vCrv[i]) then
|
||||
|
||||
-- aggiorno k per calcolo dell'offset
|
||||
local sPrevName = EgtGetName( vCrv[i-1])
|
||||
local sCurrName = EgtGetName( vCrv[i])
|
||||
if sPrevName ~= sCurrName then k = k + 1 end
|
||||
|
||||
-- se nessun raccordo modifico solo lo start point della curva
|
||||
if nLinkType == LINK_TYPE.NONE then
|
||||
local dLen = k * dSPOffs
|
||||
if dSPOffs < 0 then
|
||||
dLen = EgtCurveLength( vCrv[i]) + dLen
|
||||
end
|
||||
local dPar = EgtCurveParamAtLength( vCrv[i], dLen)
|
||||
if dPar then EgtChangeClosedCurveStart( vCrv[i], dPar) end
|
||||
|
||||
else
|
||||
-- altrimenti verifico se ha senso creare raccordo
|
||||
local dDist = dist( EgtEP( vCrv[i-1]), EgtSP( vCrv[i]))
|
||||
if dDist < dStrand + 10 then
|
||||
local nLinkId
|
||||
if k > 1 then
|
||||
-- modifico lo start point
|
||||
local dLen = EgtCurveLength( vCrv[i-1]) - abs( dSPOffs)
|
||||
EgtTrimCurveEndAtLen( vCrv[i-1], dLen)
|
||||
EgtChangeClosedCurveStartPoint( vCrv[i], EgtEP( vCrv[i-1]))
|
||||
end
|
||||
-- aggiungo il raccordo
|
||||
EgtTrimCurveEndAtLen( vCrv[i-1], EgtCurveLength( vCrv[i-1]) - dLinkParam / 2)
|
||||
EgtTrimCurveStartAtLen( vCrv[i], dLinkParam / 2)
|
||||
if nLinkType == LINK_TYPE.LINEAR then
|
||||
nLinkId = EgtCurveCompoFromPoints( nTpathGrpId, {EgtEP( vCrv[i-1]), EgtSP( vCrv[i])})
|
||||
elseif nLinkType == LINK_TYPE.BIARC then
|
||||
local frLoc = Frame3d( ORIG(), vtSlicing)
|
||||
local nGrpTmp = EgtGroup( nTpathGrpId, frLoc)
|
||||
local _, _, dAngIni = SphericalFromVector( EgtEV( vCrv[i-1], nGrpTmp))
|
||||
local _, _, dAngFin = SphericalFromVector( EgtSV( vCrv[i], nGrpTmp))
|
||||
nLinkId = EgtBiArc( nGrpTmp, EgtEP( vCrv[i-1], nGrpTmp), EgtSP( vCrv[i], nGrpTmp), dAngIni, dAngFin, 0.5)
|
||||
EgtRelocateGlob( nLinkId, nTpathGrpId, GDB_IN.LAST_SON)
|
||||
EgtErase( nGrpTmp)
|
||||
end
|
||||
|
||||
if nLinkId then
|
||||
EgtRelocate( nLinkId, vCrv[i], GDB_IN.BEFORE)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.LINK)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddLeadIn( nCrvId, LayerParams, nGrpId)
|
||||
|
||||
@@ -113,7 +175,7 @@ local function AddLeadOut( nCrvId, LayerParams, nGrpId)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRetraction( nCrvId, dCoastingLen, dWipeLen)
|
||||
local function AddRetraction( nCrvId, dCoastingLen, dWipeLen, vtSlicing)
|
||||
|
||||
-- curva ausiliaria per generare correttamente wipe
|
||||
local nCopyId = EgtCopyGlob( nCrvId, nCrvId, GDB_IN.AFTER)
|
||||
@@ -125,26 +187,43 @@ local function AddRetraction( nCrvId, dCoastingLen, dWipeLen)
|
||||
if dCoastingLen > GEO.EPS_SMALL then
|
||||
nCoastingId = EgtCopyGlob( nCrvId, nCrvId, GDB_IN.AFTER)
|
||||
local dPar = EgtCurveParamAtLength( nCoastingId, EgtCurveLength( nCoastingId) - dCoastingLen)
|
||||
if not dPar then
|
||||
EgtErase( nCopyId)
|
||||
if not dPar then
|
||||
EgtErase( nCoastingId)
|
||||
return
|
||||
end
|
||||
EgtTrimCurveStartAtParam( nCoastingId, dPar)
|
||||
-- aggiorno la curva originale
|
||||
if dPar > GEO.EPS_SMALL then
|
||||
EgtTrimCurveEndAtParam( nCrvId, dPar)
|
||||
nCoastingId = nil
|
||||
else
|
||||
EgtErase( nCrvId)
|
||||
EgtTrimCurveStartAtParam( nCoastingId, dPar)
|
||||
-- aggiorno la curva originale
|
||||
if dPar > GEO.EPS_SMALL then
|
||||
EgtTrimCurveEndAtParam( nCrvId, dPar)
|
||||
else
|
||||
EgtErase( nCrvId)
|
||||
end
|
||||
EgtSetName( nCoastingId, COASTING_CRV)
|
||||
EgtSetInfo( nCoastingId, KEY_TYPE, TYPE.COASTING)
|
||||
EgtSetColor( nCoastingId, EgtStdColor('ORANGE'))
|
||||
end
|
||||
EgtSetName( nCoastingId, COASTING_CRV)
|
||||
EgtSetInfo( nCoastingId, KEY_TYPE, TYPE.COASTING)
|
||||
EgtSetColor( nCoastingId, EgtStdColor('ORANGE'))
|
||||
end
|
||||
|
||||
if dWipeLen > GEO.EPS_SMALL then
|
||||
local nWipeId = EgtCopyGlob( nCopyId, nCoastingId or nCrvId, GDB_IN.AFTER)
|
||||
EgtTrimCurveEndAtLen( nWipeId, dWipeLen)
|
||||
-- se shell
|
||||
local nWipeId
|
||||
local nType = EgtGetInfo( nCrvId, KEY_TYPE, 'i')
|
||||
local bClosedExtraShell = EgtGetInfo( nCrvId, KEY_CLOSED_EXTRA_SHELL, 'b') or false
|
||||
if nType == TYPE.OUTER_SHELL or nType == TYPE.INNER_SHELL or bClosedExtraShell then
|
||||
-- se shell o extra shell chiusa
|
||||
nWipeId = EgtCopyGlob( nCopyId, nCoastingId or nCrvId, GDB_IN.AFTER)
|
||||
EgtTrimCurveEndAtLen( nWipeId, dWipeLen)
|
||||
else
|
||||
-- se extra shell aperta
|
||||
local bInverted = EgtGetInfo( nCrvId, KEY_INVERTED_CURVE, 'b') or false
|
||||
local vtDir = EgtEV( nCoastingId or nCrvId)
|
||||
vtDir:rotate( vtSlicing, EgtIf( bInverted, 90, -90))
|
||||
local ptS = EgtEP( nCoastingId or nCrvId)
|
||||
local ptE = ptS + vtDir * dWipeLen
|
||||
nWipeId = EgtCurveCompoFromPoints( EgtGetParent( nCrvId), {ptS, ptE})
|
||||
EgtRelocateGlob( nWipeId, nCoastingId or nCrvId, GDB_IN.AFTER)
|
||||
end
|
||||
|
||||
EgtSetName( nWipeId, WIPE_CRV)
|
||||
EgtSetInfo( nWipeId, KEY_TYPE, TYPE.WIPE)
|
||||
EgtSetColor( nWipeId, EgtStdColor('TEAL'))
|
||||
@@ -155,45 +234,62 @@ local function AddRetraction( nCrvId, dCoastingLen, dWipeLen)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRetractionOnLastCrv( nTpathGrpId, LayerParams)
|
||||
|
||||
local nCrvId = EgtGetLastNameInGroup( nTpathGrpId, SHELL_CRV .. "*")
|
||||
local function AddRetractionOnLastCrv( nCrvId, nTpathGrpId, LayerParams)
|
||||
|
||||
if LayerParams.nLeadOutType == LEAD_TYPE.NONE then
|
||||
AddRetraction( nCrvId, LayerParams.dCoastingLen, LayerParams.dWipeLen)
|
||||
AddRetraction( nCrvId, LayerParams.dCoastingLen, LayerParams.dWipeLen, LayerParams.vtSlicing)
|
||||
else
|
||||
local nLeadOutId = EgtGetLastInGroup( nTpathGrpId)
|
||||
local dLen = EgtCurveLength( nLeadOutId)
|
||||
if dLen > LayerParams.dCoastingLen - 500 * GEO.EPS_SMALL then
|
||||
-- coinvolge solo la curva di lead out
|
||||
local dNewCoastingLen = EgtIf( abs( LayerParams.dCoastingLen - dLen) < 500 * GEO.EPS_SMALL, dLen, LayerParams.dCoastingLen) -- verifico se interamente coinvolta
|
||||
AddRetraction( nLeadOutId, dNewCoastingLen, 0.0)
|
||||
AddRetraction( nLeadOutId, dNewCoastingLen, 0.0, LayerParams.vtSlicing)
|
||||
else
|
||||
-- coinvolge parte dell'ultima shell crv
|
||||
local dNewCoastingLen = LayerParams.dCoastingLen - dLen
|
||||
local nCoastingId = AddRetraction( nCrvId, dNewCoastingLen, 0.0)
|
||||
local nCoastingId = AddRetraction( nCrvId, dNewCoastingLen, 0.0, LayerParams.vtSlicing)
|
||||
EgtAddCurveCompoCurve( nCoastingId, nLeadOutId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext)
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, dStrand)
|
||||
|
||||
-- verifico se il link interseca una delle altre costolature
|
||||
local nGrp = EgtGetParent( nCurr)
|
||||
|
||||
-- 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( nLinkId, vRibsIds[i], ORIG())
|
||||
if ptInt then return false end
|
||||
local ptInt = EgtIP( nOffs, vRibsIds[i], ORIG())
|
||||
local ptInt2 = EgtIP( nLinkId, vRibsIds[i], ORIG())
|
||||
if ptInt or ptInt2 then
|
||||
EgtErase( nOffs)
|
||||
EgtErase( nTotLink)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nOffs)
|
||||
EgtErase( nTotLink)
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink)
|
||||
local function CalcRibsLink( nCurr, nNext, nLoopGrp, dStrand, bForceLink)
|
||||
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
@@ -236,7 +332,7 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
if bInvert then EgtInvertCurve( nLinkId) end
|
||||
-- verifico se è valido
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext)
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, dStrand)
|
||||
if not bValid then
|
||||
EgtErase( nLinkId)
|
||||
EgtErase( nCopyId)
|
||||
@@ -450,12 +546,12 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
-- 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'))
|
||||
-- EgtSetColor( nNewEntId, EgtStdColor('GRAY'))
|
||||
end
|
||||
|
||||
-- estraggo i contorni di tutte le superfici di offset
|
||||
local nLoopGrp = EgtGroup( nRibsGrp)
|
||||
local nSrfId = EgtGetFirstNameInGroup( nRibsGrp, LAYER_SRF)
|
||||
local nSrfId = EgtGetFirstNameInGroup( nRibsGrp, TOT_SHELL_TRIM_SURF)
|
||||
while nSrfId do
|
||||
local nChunksNbr = EgtSurfFrChunkCount( nSrfId)
|
||||
for i = 0, nChunksNbr do
|
||||
@@ -468,7 +564,7 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
end
|
||||
end
|
||||
end
|
||||
nSrfId = EgtGetNextName( nSrfId, LAYER_SRF)
|
||||
nSrfId = EgtGetNextName( nSrfId, TOT_SHELL_TRIM_SURF)
|
||||
end
|
||||
|
||||
-- recupero i gruppi delle costolature
|
||||
@@ -488,7 +584,7 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
-- orientamento del primo gruppo di curve
|
||||
local bInvert = EgtGetInfo( tabRibs[1][1], KEY_RIBS_INVERT_DIR, 'b')
|
||||
if not bSpecialCase then
|
||||
for i = 1, #tabRibs do
|
||||
for i = 1, #tabRibs do
|
||||
local nInfo = EgtGetInfo( tabRibs[i][1], KEY_SPLIT_RIB, 'i')
|
||||
local nShellsNbr = EgtGetInfo( tabRibs[i][1], KEY_RIBS_SHELLS_NBR, 'i')
|
||||
-- aggiorno bInvert per il gruppo di costolature analizzato
|
||||
@@ -534,15 +630,15 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
-- collego le passate di una stessa costolatura
|
||||
for i = 1, #tabRibs do
|
||||
for j = 1, #tabRibs[i] - 1 do
|
||||
CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, true)
|
||||
CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, LayerParams.dStrand, true)
|
||||
if not bSpecialCase then
|
||||
-- creo link fittizio per eliminare tratto corrispondente sulla curva di offset
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][j + 1], tabRibs[i][j], nLoopGrp, false)
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][j + 1], tabRibs[i][j], nLoopGrp, LayerParams.dStrand, false)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
end
|
||||
if bSpecialCase then
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][#tabRibs[i]], tabRibs[i][1], nLoopGrp, false)
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][#tabRibs[i]], tabRibs[i][1], nLoopGrp, LayerParams.dStrand, false)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
end
|
||||
@@ -550,7 +646,7 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ)
|
||||
if LayerParams.bRibsLink then
|
||||
for i = 1, #tabRibs - 1 do
|
||||
local nCnt = #tabRibs[i]
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, false)
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, LayerParams.dStrand, false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -634,11 +730,12 @@ 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)
|
||||
-- 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
|
||||
-- eventuale inversione
|
||||
if EgtCurveIsClosed( nNewEntId) and LayerParams.bInvert then
|
||||
EgtInvertCurve( nNewEntId)
|
||||
end
|
||||
EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
@@ -646,63 +743,32 @@ function CalcToolPath.Exec( nPartId)
|
||||
nEntId = EgtGetNext( nEntId)
|
||||
end
|
||||
|
||||
-- aggiungo gli opportuni raccordi
|
||||
local nPrevId = EgtGetFirstInGroup( nTpathGrpId)
|
||||
local nCurrId = EgtGetNext( nPrevId or GDB_ID.NULL)
|
||||
k = 0
|
||||
local nPrevShellNbr
|
||||
if nPrevId then nPrevShellNbr = tonumber( EgtGetName( nPrevId):sub(6)) end
|
||||
while nCurrId do
|
||||
|
||||
local nCurrShellNbr = tonumber( EgtGetName( nCurrId):sub(6))
|
||||
if nCurrShellNbr ~= nPrevShellNbr then k = k + 1 end
|
||||
|
||||
-- se nessun raccordo modifico solo lo start point della curva
|
||||
if LayerParams.nLinkType == LINK_TYPE.NONE then
|
||||
local dLen = k * LayerParams.dSPOffs
|
||||
if LayerParams.dSPOffs < 0 then
|
||||
dLen = EgtCurveLength( nCurrId) + dLen
|
||||
end
|
||||
local dPar = EgtCurveParamAtLength( nCurrId, dLen)
|
||||
if dPar then EgtChangeClosedCurveStart( nCurrId, dPar) end
|
||||
|
||||
else
|
||||
-- altrimenti verifico se ha senso creare raccordo
|
||||
if abs( dist( EgtEP( nPrevId), EgtSP( nCurrId))) < LayerParams.dStrand + 10 then
|
||||
local nLinkId
|
||||
if k > 1 then
|
||||
-- modifico lo start point
|
||||
local dLen = EgtCurveLength( nPrevId) - abs( LayerParams.dSPOffs)
|
||||
EgtTrimCurveEndAtLen( nPrevId, dLen)
|
||||
EgtChangeClosedCurveStartPoint( nCurrId, EgtEP( nPrevId))
|
||||
end
|
||||
-- aggiungo il raccordo
|
||||
EgtTrimCurveEndAtLen( nPrevId, EgtCurveLength( nPrevId) - LayerParams.dLinkParam / 2)
|
||||
EgtTrimCurveStartAtLen( nCurrId, LayerParams.dLinkParam / 2)
|
||||
if LayerParams.nLinkType == LINK_TYPE.LINEAR then
|
||||
nLinkId = EgtCurveCompoFromPoints( nTpathGrpId, {EgtEP( nPrevId), EgtSP( nCurrId)})
|
||||
elseif LayerParams.nLinkType == LINK_TYPE.BIARC then
|
||||
local frLoc = Frame3d( ORIG(), LayerParams.vtSlicing)
|
||||
local nGrpTmp = EgtGroup( nTpathGrpId, frLoc)
|
||||
local _, _, dAngIni = SphericalFromVector( EgtEV( nPrevId, nGrpTmp))
|
||||
local _, _, dAngFin = SphericalFromVector( EgtSV( nCurrId, nGrpTmp))
|
||||
nLinkId = EgtBiArc( nGrpTmp, EgtEP( nPrevId, nGrpTmp), EgtSP( nCurrId, nGrpTmp), dAngIni, dAngFin, 0.5)
|
||||
EgtRelocateGlob( nLinkId, nTpathGrpId, GDB_IN.LAST_SON)
|
||||
EgtErase( nGrpTmp)
|
||||
end
|
||||
|
||||
if nLinkId then
|
||||
EgtRelocate( nLinkId, nCurrId, GDB_IN.BEFORE)
|
||||
EgtModifyCurveExtrusion( nLinkId, LayerParams.vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.LINK)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
nPrevShellNbr = nCurrShellNbr
|
||||
nPrevId = nCurrId
|
||||
nCurrId = EgtGetNext( nCurrId)
|
||||
-- aggiungo gli opportuni raccordi sulle shell complete
|
||||
local vIds = EgtGetNameInGroup( nTpathGrpId, SHELL_CRV .. '*')
|
||||
local vIdsExtra = EgtGetNameInGroup( nTpathGrpId, EXTRA_SHELL_CRV .. '*') or {}
|
||||
for i = 1, #vIdsExtra do
|
||||
table.insert( vIds, vIdsExtra[i])
|
||||
end
|
||||
AddLink( vIds, nTpathGrpId, LayerParams.nLinkType, LayerParams.dLinkParam, LayerParams.dSPOffs, LayerParams.dStrand, LayerParams.vtSlicing)
|
||||
|
||||
-- aggiungo gli opportuni raccondi sulle shell con numero diverso di passate
|
||||
local nPrev = EgtGetFirstNameInGroup( nTpathGrpId, EXTRA_SHELL_CRV .. '*')
|
||||
local sPrevName = EgtGetName( nPrev or GDB_ID.NULL)
|
||||
local nCurr = EgtGetNextName( nPrev or GDB_ID.NULL, EXTRA_SHELL_CRV .. '*')
|
||||
while nCurr do
|
||||
local sCurrName = EgtGetName( nCurr)
|
||||
if sCurrName == sPrevName then
|
||||
local ptS = EgtEP( nPrev)
|
||||
local ptE = EgtSP( nCurr)
|
||||
local nLinkId = EgtCurveCompoFromPoints( nTpathGrpId, {ptS, ptE})
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.BEFORE)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.LINK)
|
||||
end
|
||||
sPrevName = sCurrName
|
||||
nPrev = nCurr
|
||||
nCurr = EgtGetNextName( nCurr, EXTRA_SHELL_CRV .. '*')
|
||||
end
|
||||
|
||||
|
||||
-- aggiungo leadin/leadout
|
||||
local nFirstCurve = EgtGetFirstInGroup( nTpathGrpId)
|
||||
@@ -719,23 +785,23 @@ function CalcToolPath.Exec( nPartId)
|
||||
-- aggiungo coasting/wipe
|
||||
local nId = EgtGetFirstNameInGroup( nTpathGrpId, SHELL_CRV .. "*")
|
||||
local nFirstId = nId
|
||||
local nLastId = EgtGetLastNameInGroup( nTpathGrpId, SHELL_CRV .. "*")
|
||||
while nId do
|
||||
local nLastId = EgtGetLastNameInGroup( nTpathGrpId, EXTRA_SHELL_CRV .. "*") or EgtGetLastNameInGroup( nTpathGrpId, SHELL_CRV .. "*")
|
||||
while nId do
|
||||
if nId == nLastId then
|
||||
AddRetractionOnLastCrv( nTpathGrpId, LayerParams)
|
||||
AddRetractionOnLastCrv( nId, nTpathGrpId, LayerParams)
|
||||
else
|
||||
local nNextId = EgtGetNext( nId)
|
||||
if EgtGetInfo( nNextId, KEY_TYPE, 'i') ~= TYPE.LINK then
|
||||
-- aggiungo retrazione
|
||||
if nId == nFirstId then
|
||||
local dWipeLen = EgtIf( LayerParams.nLeadInType == LEAD_TYPE.NONE, LayerParams.dWipeLen, 0)
|
||||
AddRetraction( nId, LayerParams.dCoastingLen, dWipeLen)
|
||||
AddRetraction( nId, LayerParams.dCoastingLen, dWipeLen, LayerParams.vtSlicing)
|
||||
else
|
||||
AddRetraction( nId, LayerParams.dCoastingLen, LayerParams.dWipeLen)
|
||||
AddRetraction( nId, LayerParams.dCoastingLen, LayerParams.dWipeLen, LayerParams.vtSlicing)
|
||||
end
|
||||
end
|
||||
end
|
||||
nId = EgtGetNextName( nId, SHELL_CRV .. "*")
|
||||
nId = EgtGetNextName( nId, SHELL_CRV .. "*") or EgtGetNextName( nId, EXTRA_SHELL_CRV .. "*")
|
||||
end
|
||||
|
||||
-- sistemo le costolature
|
||||
|
||||
@@ -18,6 +18,10 @@ local function ShowImportedSolid( nPartId, bShow)
|
||||
EgtSetStatus( nSolidLayId or GDB_ID.NULL, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
|
||||
local nRibsLayId = EgtGetFirstNameInGroup( nPartId, LAY_RIBS)
|
||||
EgtSetStatus( nRibsLayId or GDB_ID.NULL, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
|
||||
local nShellNbrLay = EgtGetFirstNameInGroup( nPartId, LAY_SHELL_NBR)
|
||||
EgtSetStatus( nShellNbrLay or GDB_ID.NULL, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
|
||||
local nAuxSolidsLay = EgtGetFirstNameInGroup( nPartId, LAY_AUX_SOLIDS)
|
||||
EgtSetStatus( nAuxSolidsLay or GDB_ID.NULL, EgtIf( bShow, GDB_ST.ON, GDB_ST.OFF))
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
@@ -30,9 +30,12 @@ local function CalcType( nEntId, nOldType)
|
||||
if not nType or nType == TYPE.LINK or nType == TYPE.COASTING or nType == TYPE.WIPE then
|
||||
nType = nOldType
|
||||
end
|
||||
if nType == TYPE.RIB then
|
||||
if nType == TYPE.RIB or nType == TYPE.AUX_SOLID then
|
||||
nType = TYPE.INFILL
|
||||
end
|
||||
if nType == TYPE.EXTRA_SHELL then
|
||||
nType = TYPE.INNER_SHELL
|
||||
end
|
||||
return nType
|
||||
end
|
||||
|
||||
|
||||
@@ -118,7 +118,10 @@ local function LoadParams( sFile, nPartId)
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_LEAD_OUT_LEN, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_LEAD_OUT_COASTING, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_LEAD_OUT_WIPE, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_LEAD_OUT_WIPE_DIR, '0.0')
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_LEAD_OUT_WIPE_DIR, '0.0')
|
||||
|
||||
-- parametri per regioni con diverso numero di passate
|
||||
SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELL_NBR_DIFF, '0')
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -196,6 +199,7 @@ function RunSlicing.Exec()
|
||||
return
|
||||
end
|
||||
local nRibsLayId = EgtGetFirstNameInGroup( nPartId, LAY_RIBS)
|
||||
local nShellNbrLay = EgtGetFirstNameInGroup( nPartId, LAY_SHELL_NBR)
|
||||
local nStartLayId = EgtGetFirstNameInGroup( nPartId, LAY_MACH_START)
|
||||
|
||||
-- Scelta del file dei parametri
|
||||
@@ -250,6 +254,7 @@ function RunSlicing.Exec()
|
||||
CSOLIDS.Exec( nPartId)
|
||||
EgtSetStatus( nSolidLayId, GDB_ST.OFF)
|
||||
EgtSetStatus( nRibsLayId or GDB_ID.NULL, GDB_ST.OFF)
|
||||
EgtSetStatus( nShellNbrLay or GDB_ID.NULL, GDB_ST.OFF)
|
||||
EgtSetStatus( nStartLayId or GDB_ID.NULL, GDB_ST.OFF)
|
||||
EgtDraw()
|
||||
|
||||
|
||||
@@ -31,9 +31,12 @@ local function CalcType( nEntId, nOldType)
|
||||
if not nType or nType == TYPE.LINK or nType == TYPE.COASTING or nType == TYPE.WIPE then
|
||||
nType = nOldType
|
||||
end
|
||||
if nType == TYPE.RIB then
|
||||
if nType == TYPE.RIB or nType == TYPE.AUX_SOLID then
|
||||
nType = TYPE.INFILL
|
||||
end
|
||||
if nType == TYPE.EXTRA_SHELL then
|
||||
nType = TYPE.INNER_SHELL
|
||||
end
|
||||
return nType
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user