Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a595fcdb98 | |||
| 43949d7f13 | |||
| 00700f3194 | |||
| 28686fe6b6 | |||
| 4a4a7d648b |
@@ -172,6 +172,7 @@ KEY_SPEED_MIN = "SpeedMin"
|
||||
KEY_SPEED_MAX = "SpeedMax"
|
||||
|
||||
-- Altre chiavi
|
||||
KEY_MAX_H = "SlicingHeight"
|
||||
KEY_SLICE_NBR = "SliceNbr"
|
||||
KEY_SLICE_Z = "SliceZ"
|
||||
KEY_SLICE_DELTAZ = "DeltaZ"
|
||||
@@ -194,6 +195,7 @@ KEY_INTERNAL_SRF_LOOP = "InternalSrfLoop"
|
||||
KEY_PREV_CRV = "PrevCrv"
|
||||
KEY_NEXT_CRVS = "NextCrvs"
|
||||
KEY_CRV_STRAND = "CurveStrand"
|
||||
KEY_LAYER_CNT = "LayerCnt"
|
||||
|
||||
SLICING_TYPE = {
|
||||
VERTICAL = 1,
|
||||
|
||||
+81
-35
@@ -25,6 +25,7 @@ local function GetLayerParamsForPathCalc()
|
||||
LayerParams.nShellsNbr = EgtGetInfo( s_nPartId, KEY_SHELLS_NBR, 'i')
|
||||
LayerParams.dStrand = EgtGetInfo( s_nPartId, KEY_STRAND, 'd')
|
||||
LayerParams.dInnerStrand = EgtGetInfo( s_nPartId, KEY_INNER_STRAND, 'd') or LayerParams.dStrand
|
||||
LayerParams.dInnerStrand = EgtClamp( LayerParams.dInnerStrand, 0.5 * LayerParams.dStrand, 1.5 * LayerParams.dStrand)
|
||||
LayerParams.dLayHeight = EgtGetInfo( s_nPartId, KEY_SLICE_STEP, 'd')
|
||||
LayerParams.dStrandOverlap = EgtGetInfo( s_nPartId, KEY_STRAND_OVERLAP, 'd') or 0
|
||||
LayerParams.dOffs = EgtGetInfo( s_nPartId, KEY_OFFSET_SLICE, 'd')
|
||||
@@ -44,6 +45,7 @@ local function GetLayerParamsForPathCalc()
|
||||
LayerParams.nCeilType = EgtGetInfo( s_nPartId, KEY_CEIL_TYPE, 'i') or FILL_TYPE.OFFSET
|
||||
-- parametri infill
|
||||
LayerParams.dInfillStrand = EgtGetInfo( s_nPartId, KEY_INFILL_STRAND, 'd') or LayerParams.dStrand
|
||||
LayerParams.dInfillStrand = EgtClamp( LayerParams.dInfillStrand, 0.5 * LayerParams.dStrand, 1.5 * LayerParams.dStrand)
|
||||
LayerParams.bInfillLink = EgtGetInfo( s_nPartId, KEY_INFILL_LINK, 'b') or false
|
||||
LayerParams.dInfillOverlap = EgtGetInfo( s_nPartId, KEY_INFILL_OVERLAP, 'd') or 0
|
||||
LayerParams.nInfillType = EgtGetInfo( s_nPartId, KEY_INFILL_TYPE, 'i') or FILL_TYPE.NONE
|
||||
@@ -2577,7 +2579,9 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
|
||||
|
||||
local dAlpha = 1.2
|
||||
|
||||
-- verifico se posso unire due tratti consecutivi della stessa shell
|
||||
local nFirst = EgtGetFirstNameInGroup( nPathGrp, EXTRA_SHELL_CRV .. '*')
|
||||
while nFirst do
|
||||
@@ -2588,7 +2592,7 @@ local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
local dStrand = EgtIf( nType == TYPE.EXTRA_OUTER_SHELL, LayerParams.dStrand, LayerParams.dInnerStrand)
|
||||
local nCurr = vShells[1]
|
||||
for i = 2, #vShells do
|
||||
if dist( EgtEP( nCurr), EgtSP( vShells[i])) < dStrand + GEO.EPS_SMALL then
|
||||
if dist( EgtEP( nCurr), EgtSP( vShells[i])) < dAlpha * dStrand + GEO.EPS_SMALL then
|
||||
-- unisco le curve
|
||||
EgtAddCurveCompoLine( nCurr, EgtSP( vShells[i]))
|
||||
EgtAddCurveCompoCurve( nCurr, vShells[i])
|
||||
@@ -2597,7 +2601,7 @@ local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
end
|
||||
end
|
||||
-- check su prima e ultima curva
|
||||
if nCurr ~= nFirst and dist( EgtEP( nCurr), EgtSP( nFirst)) < dStrand + GEO.EPS_SMALL then
|
||||
if nCurr ~= nFirst and dist( EgtEP( nCurr), EgtSP( nFirst)) < dAlpha * dStrand + GEO.EPS_SMALL then
|
||||
-- unisco le curve
|
||||
EgtAddCurveCompoLine( nCurr, EgtSP( nFirst))
|
||||
EgtAddCurveCompoCurve( nCurr, nFirst)
|
||||
@@ -2607,7 +2611,7 @@ local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
vShells = EgtGetNameInGroup( nPathGrp, sName)
|
||||
for i = 1, #vShells do
|
||||
if not EgtCurveIsClosed( vShells[i]) then
|
||||
if dist( EgtSP( vShells[i]), EgtEP( vShells[i])) < dStrand + GEO.EPS_SMALL then
|
||||
if dist( EgtSP( vShells[i]), EgtEP( vShells[i])) < dAlpha * dStrand + GEO.EPS_SMALL then
|
||||
EgtCloseCurveCompo( vShells[i])
|
||||
end
|
||||
end
|
||||
@@ -2628,38 +2632,42 @@ local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
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
|
||||
local nCurrCrv = vIds[1]
|
||||
table.remove( vIds, 1)
|
||||
EgtSetName( nCurrCrv, EXTRA_SHELL_CRV .. tostring(k))
|
||||
|
||||
local k = 1 -- indice da utilizzare per i nomi
|
||||
local vUsed = {} -- flag per indicare se corrispondente elemento di vIds è già stato considerato
|
||||
for i = 1, #vIds do
|
||||
vUsed[i] = false
|
||||
end
|
||||
|
||||
local nCurr = vIds[1]
|
||||
vUsed[1] = true
|
||||
EgtSetName( nCurr, EXTRA_SHELL_CRV .. tostring(k))
|
||||
while nCurr do
|
||||
local bEndChain = false
|
||||
local nCnt = 0
|
||||
-- se curva è chiusa
|
||||
if EgtCurveIsClosed( nCurrCrv) then
|
||||
ModifyStartPoint( nCurrCrv, vPtStart)
|
||||
-- setto a nil per ripartire subito con curva successiva
|
||||
nCurrCrv = nil
|
||||
local vLinkedShells = { nCurr}
|
||||
local dCurrStrand
|
||||
local bSameStrand = true
|
||||
|
||||
if EgtCurveIsClosed( nCurr) then
|
||||
ModifyStartPoint( nCurr, vPtStart)
|
||||
-- se è chiusa costituisce già una catena
|
||||
bEndChain = true
|
||||
end
|
||||
|
||||
-- scorro alla ricerca di una curva che posso collegare alla corrente
|
||||
while nCurrCrv do
|
||||
local ptSCurr = EgtSP( nCurrCrv)
|
||||
local ptECurr = EgtEP( nCurrCrv)
|
||||
while not bEndChain do
|
||||
local ptSCurr = EgtSP( nCurr)
|
||||
local ptECurr = EgtEP( nCurr)
|
||||
local nCurrType = EgtGetInfo( nCurr, KEY_TYPE, 'i')
|
||||
dCurrStrand = EgtIf( nCurrType == TYPE.EXTRA_OUTER_SHELL, LayerParams.dStrand, LayerParams.dInnerStrand)
|
||||
|
||||
local bFound = false
|
||||
local nCurrType = EgtGetInfo( nCurrCrv, KEY_TYPE, 'i')
|
||||
local dCurrStrand = EgtIf( nCurrType == TYPE.EXTRA_OUTER_SHELL, LayerParams.dStrand, LayerParams.dInnerStrand)
|
||||
for j = 1, #vIds do
|
||||
|
||||
if not EgtCurveIsClosed( vIds[j]) then
|
||||
if not vUsed[j] and not EgtCurveIsClosed( vIds[j]) then
|
||||
local ptS = EgtSP( vIds[j])
|
||||
local ptE = EgtEP( vIds[j])
|
||||
|
||||
local nTypeJ = EgtGetInfo( vIds[j], KEY_TYPE, 'i')
|
||||
local dStrandJ = EgtIf( nTypeJ == TYPE.EXTRA_OUTER_SHELL, LayerParams.dStrand, LayerParams.dInnerStrand)
|
||||
local dVal = 1.5 * max( dCurrStrand, dStrandJ)
|
||||
local dVal = dAlpha * max( dCurrStrand, dStrandJ)
|
||||
|
||||
local bLink = false
|
||||
if dist( ptECurr, ptE) < dVal then
|
||||
@@ -2672,30 +2680,60 @@ local function ReorderExtraShells( nPathGrp, vPtStart, LayerParams)
|
||||
bLink = true
|
||||
elseif nCnt == 0 and dist( ptSCurr, ptS) < dVal then
|
||||
-- congiungo start-start
|
||||
EgtInvertCurve( nCurrCrv)
|
||||
UpdateInvertInfo( nCurrCrv)
|
||||
EgtInvertCurve( nCurr)
|
||||
UpdateInvertInfo( nCurr)
|
||||
bLink = true
|
||||
end
|
||||
|
||||
if bLink then
|
||||
nCnt = nCnt + 1
|
||||
EgtRelocateGlob( vIds[j], nCurrCrv, GDB_IN.AFTER)
|
||||
EgtRelocateGlob( vIds[j], nCurr, GDB_IN.AFTER)
|
||||
EgtSetName( vIds[j], EXTRA_SHELL_CRV .. tostring( k))
|
||||
table.insert( vLinkedShells, vIds[j])
|
||||
if abs( dStrandJ - dCurrStrand) > GEO.EPS_SMALL then
|
||||
bSameStrand = false
|
||||
end
|
||||
|
||||
-- aggiorno per collegamento successivo
|
||||
bFound = true
|
||||
nCurrCrv = vIds[j]
|
||||
table.remove( vIds, j)
|
||||
nCurr = vIds[j]
|
||||
vUsed[j] = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se non ho più curve da collegare
|
||||
if not bFound then
|
||||
nCurrCrv = nil
|
||||
|
||||
-- se non ho trovato setti da collegare la catena è finita, altrimenti posso cercare successivo
|
||||
bEndChain = not bFound
|
||||
end
|
||||
|
||||
-- verifico se posso unire tutti i tratti appena trovati
|
||||
if #vLinkedShells > 1 and bSameStrand and EgtGetInfo( vLinkedShells[1], KEY_TYPE, 'i') == TYPE.EXTRA_OUTER_SHELL and
|
||||
dist( EgtSP( vLinkedShells[1]), EgtEP( vLinkedShells[#vLinkedShells])) < dAlpha * dCurrStrand + GEO.EPS_SMALL then
|
||||
-- unisco le curve
|
||||
for i = 2, #vLinkedShells do
|
||||
EgtAddCurveCompoLine( vLinkedShells[1], EgtSP( vLinkedShells[i]))
|
||||
EgtAddCurveCompoCurve( vLinkedShells[1], vLinkedShells[i])
|
||||
end
|
||||
EgtCloseCurveCompo( vLinkedShells[1])
|
||||
|
||||
ModifyStartPoint( vLinkedShells[1], vPtStart)
|
||||
EgtSetInfo( vLinkedShells[1], KEY_CLOSED_CRV, true)
|
||||
end
|
||||
|
||||
-- cerco il prossimo da cui partire
|
||||
nCurr = nil
|
||||
for i = 1, #vIds do
|
||||
if not vUsed[i] then
|
||||
nCurr = vIds[i]
|
||||
vUsed[i] = true
|
||||
k = k + 1
|
||||
EgtSetName( nCurr, EXTRA_SHELL_CRV .. tostring(k))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
@@ -2772,6 +2810,14 @@ local function CalcExtraShellsPath( nMaxShellNbrDiff, nShellNbrGrp, nCrvGrpId, d
|
||||
|
||||
local nCrv, nCnt = EgtTrimCurveWithRegion( nCrvOffs, nTrimSurf, true, true)
|
||||
if nCrv and nCnt ~= 0 then
|
||||
-- verifico se posso unire primo e ultimo tratto
|
||||
if nCrv and nCnt > 1 and AreSamePointApprox( EgtEP( nCrv + nCnt - 1), EgtSP( nCrv)) then
|
||||
EgtRelocateGlob( nCrv + nCnt - 1, nCrv, GDB_IN.AFTER)
|
||||
EgtAddCurveCompoCurve( nCrv + nCnt - 1, nCrv)
|
||||
EgtChangeId( nCrv + nCnt - 1, nCrv)
|
||||
nCnt = nCnt - 1
|
||||
end
|
||||
|
||||
for nId = nCrv, nCrv + nCnt - 1 do
|
||||
local dLen = EgtCurveLength( nId)
|
||||
local bValid = true
|
||||
|
||||
+21
-6
@@ -1,4 +1,4 @@
|
||||
-- CalcSlices.lua by Egaltech s.r.l. 2022/10/12
|
||||
-- CalcSlices.lua by Egaltech s.r.l. 2023/08/28
|
||||
-- Calcolo percorsi di lavoro per Stampa 3d
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -37,7 +37,12 @@ local function ComputeZSlices( dSliceStep, dZmin, dDeltaZ, dZmax)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeMaxH( vIds, frSlicing, HMax, dSliceStep)
|
||||
local function ComputeMaxH( vIds, frSlicing, dSliceStep)
|
||||
|
||||
local HMax = EgtGetInfo( s_nPartId, KEY_MAX_H, 'd') or GEO.INFINITO
|
||||
if HMax < GEO.EPS_SMALL then
|
||||
HMax = GEO.INFINITO
|
||||
end
|
||||
|
||||
-- calcolo il box globale
|
||||
local b3BoxGlob = BBox3d()
|
||||
@@ -99,6 +104,7 @@ local function GetRibParams( nId)
|
||||
|
||||
local RibParam = {}
|
||||
ReadParam( nId, KEY_RIBS_STRAND, 'd', s_dStrand, RibParam)
|
||||
RibParam[KEY_RIBS_STRAND] = EgtClamp( RibParam[KEY_RIBS_STRAND], 0.5 * s_dStrand, 1.5 * s_dStrand)
|
||||
ReadParam( nId, KEY_RIBS_SHELLS_NBR, 'i', 0, RibParam)
|
||||
ReadParam( nId, KEY_RIBS_INVERT_DIR, 'b', false, RibParam)
|
||||
ReadParam( nId, KEY_RIBS_LEAD_IN_INVERT, 'b', false, RibParam)
|
||||
@@ -133,6 +139,7 @@ local function GetAuxSolidsParams( nId)
|
||||
|
||||
local AuxSolidsParam = {}
|
||||
ReadParam( nId, KEY_AUX_SOLIDS_STRAND, 'd', s_dStrand, AuxSolidsParam)
|
||||
AuxSolidsParam[KEY_AUX_SOLIDS_STRAND] = EgtClamp( AuxSolidsParam[KEY_AUX_SOLIDS_STRAND], 0.5 * s_dStrand, 1.5 * s_dStrand)
|
||||
ReadParam( nId, KEY_AUX_SOLIDS_SHELLS_NBR, 'i', 0, AuxSolidsParam)
|
||||
ReadParam( nId, KEY_AUX_SOLIDS_OVERLAP, 'd', 0, AuxSolidsParam)
|
||||
ReadParam( nId, KEY_AUX_SOLIDS_INFILL, 'i', FILL_TYPE.NONE, AuxSolidsParam)
|
||||
@@ -624,6 +631,7 @@ local function PrepareInfill( nStmId, vtSlicing)
|
||||
local dGridOverlap = EgtGetInfo( s_nPartId, KEY_INFILL_GRID_OVERLAP, 'd') or 0
|
||||
local dOffsStm = EgtGetInfo( s_nPartId, KEY_OFFSET_SLICE, 'd')
|
||||
local dStrand = EgtGetInfo( s_nPartId, KEY_INFILL_STRAND, 'd') or s_dStrand
|
||||
dStrand = EgtClamp( dStrand, 0.5 * s_dStrand, 1.5 * s_dStrand)
|
||||
|
||||
-- creo gruppo per infill
|
||||
local nInfillGrp = EgtGroup( s_nPartId)
|
||||
@@ -657,6 +665,7 @@ local function PrepareAuxSolidsInfill( nSolidsLay, vtSlicing)
|
||||
local dOffsY = ReadParam( vIds[i], KEY_AUX_SOLIDS_OFFSET_Y, 'd', 0)
|
||||
local dGridOverlap = ReadParam( vIds[i], KEY_AUX_SOLIDS_GRID_OVERLAP, 'd', 0)
|
||||
local dStrand = ReadParam( vIds[i], KEY_AUX_SOLIDS_STRAND, 'd', s_dStrand)
|
||||
dStrand = EgtClamp( dStrand, 0.5 * s_dStrand, 1.5 * s_dStrand)
|
||||
|
||||
-- creo gruppo associato
|
||||
local nInfillGrp = EgtGroup( s_nPartId)
|
||||
@@ -1056,17 +1065,23 @@ local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function CalcSlices.Exec( nPartId, nStmId, HMax)
|
||||
function CalcSlices.Exec( nPartId, nStmId)
|
||||
|
||||
s_nPartId = nPartId
|
||||
|
||||
local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini'
|
||||
|
||||
-- recupero la direzione dello slicing
|
||||
local vtSlicing = Z_AX()
|
||||
local nSlicingType = EgtGetInfo( s_nPartId, KEY_SLICING_TYPE, 'i')
|
||||
if nSlicingType == SLICING_TYPE.DEG45_X then
|
||||
vtSlicing = VectorFromSpherical( 1, 45, 0)
|
||||
local nDir = EgtGetNumberFromIni( '3dPrinting', 'Dir45degX', 0, sMachIni)
|
||||
local dHorAng = EgtIf( nDir == -1, 180, 0)
|
||||
vtSlicing = VectorFromSpherical( 1, 45, dHorAng)
|
||||
elseif nSlicingType == SLICING_TYPE.DEG45_Y then
|
||||
vtSlicing = VectorFromSpherical( 1, 45, -90)
|
||||
local nDir = EgtGetNumberFromIni( '3dPrinting', 'Dir45degY', 0, sMachIni)
|
||||
local dHorAng = EgtIf( nDir == 2, 90, -90)
|
||||
vtSlicing = VectorFromSpherical( 1, 45, dHorAng)
|
||||
elseif nSlicingType == SLICING_TYPE.HORIZONTAL then
|
||||
vtSlicing = X_AX()
|
||||
end
|
||||
@@ -1115,7 +1130,7 @@ function CalcSlices.Exec( nPartId, nStmId, HMax)
|
||||
|
||||
local dZmin = b3Box:getMin():getZ()
|
||||
local dZmax = b3Box:getMax():getZ()
|
||||
local dMaxH = ComputeMaxH( vRefIds, frSlicing, HMax, dSliceStep)
|
||||
local dMaxH = ComputeMaxH( vRefIds, frSlicing, dSliceStep)
|
||||
dZmax = min( dZmax, dMaxH)
|
||||
--dZmin = 708
|
||||
--dZmax = 712
|
||||
|
||||
+162
-63
@@ -23,6 +23,7 @@ local function GetLayerParamsForToolPathCalc()
|
||||
LayerParams.bSpiralVase = EgtGetInfo( s_nPartId, KEY_SPIRAL_VASE, 'b') or false
|
||||
LayerParams.dStrand = EgtGetInfo( s_nPartId, KEY_STRAND, 'd')
|
||||
LayerParams.dInnerStrand = EgtGetInfo( s_nPartId, KEY_INNER_STRAND, 'd') or LayerParams.dStrand
|
||||
LayerParams.dInnerStrand = EgtClamp( LayerParams.dInnerStrand, 0.5 * LayerParams.dStrand, 1.5 * LayerParams.dStrand)
|
||||
LayerParams.dLayHeight = EgtGetInfo( s_nPartId, KEY_SLICE_STEP, 'd')
|
||||
LayerParams.dOffs = EgtGetInfo( s_nPartId, KEY_OFFSET_SLICE, 'd')
|
||||
LayerParams.bInvert = ( EgtGetInfo( s_nPartId, KEY_PRINT_DIRECTION, 'i') == PRINT_DIRECTION.CW)
|
||||
@@ -45,6 +46,7 @@ local function GetLayerParamsForToolPathCalc()
|
||||
LayerParams.dTDiam = EgtGetInfo( s_nPartId, KEY_TOOL_DIAM, 'd')
|
||||
-- parametri infill
|
||||
LayerParams.dInfillStrand = EgtGetInfo( s_nPartId, KEY_INFILL_STRAND, 'd') or LayerParams.dStrand
|
||||
LayerParams.dInfillStrand = EgtClamp( LayerParams.dInfillStrand, 0.5 * LayerParams.dStrand, 1.5 * LayerParams.dStrand)
|
||||
LayerParams.bInfillLink = EgtGetInfo( s_nPartId, KEY_INFILL_LINK, 'b') or false
|
||||
LayerParams.dInfillCoasting = EgtGetInfo( s_nPartId, KEY_INFILL_COASTING, 'd') or 0
|
||||
LayerParams.dInfillWipe = EgtGetInfo( s_nPartId, KEY_INFILL_WIPE, 'd') or 0
|
||||
@@ -582,7 +584,15 @@ local function CalcExtraShellToolPath( vEntIds, nTpathGrpId, LayerParams)
|
||||
end
|
||||
sPrevName = sCurrName
|
||||
end
|
||||
|
||||
|
||||
-- aggiungo offset lead point sulle extra shell chiuse
|
||||
for i = 1, #vIds do
|
||||
if EgtCurveIsClosed( vIds[i]) then
|
||||
local nCopy = EgtCopyGlob( nTpathGrpId, vIds[i])
|
||||
AddOffsetLeadPoint( {vIds[i]}, nCopy, LayerParams.dOffsetLP, LINK_TYPE.NONE)
|
||||
end
|
||||
end
|
||||
|
||||
-- aggiungo coasting/wipe
|
||||
for i = 1, #vIds do
|
||||
-- verifico non sia collegato al successivo tramite link
|
||||
@@ -702,8 +712,8 @@ local function VerifyInfillLink( nLinkId, nCurr, nNext, vIds, dStrand, nGrpTmp)
|
||||
-- se tratto lineare allineato come curva corrente
|
||||
if AreSameVectorApprox( vtS, vtE) and vtS * vtDirCurr < - 1 + GEO.EPS_SMALL then
|
||||
-- verifico distanza
|
||||
local nCrvTest = EgtCurveCompoFromPoints( nGrpTmp, { EgtUP( nCurrLoc, dPar), EgtUP( nCurrLoc, dPar + 1)})
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLinkLoc, dParCrv - 0.5), nNextLoc)
|
||||
local nCrvTest = EgtCurveCompoFromPoints( nGrpTmp, { EgtUP( nNextLoc, dPar), EgtUP( nNextLoc, dPar + 1)})
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLinkLoc, dParCrv - 0.5), nCrvTest)
|
||||
if dDist < dMinDist + GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
@@ -1014,18 +1024,46 @@ end
|
||||
--------------------------------------------------------------------
|
||||
--------------------------- RIBS -----------------------------------
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
|
||||
local dStrand = EgtGetInfo( nLinkId, KEY_CRV_STRAND, 'd')
|
||||
local dOverlap1 = EgtGetInfo( nCurr, KEY_RIBS_OVERLAP, 'd')
|
||||
local dOverlap2 = EgtGetInfo( nNext, KEY_RIBS_OVERLAP, 'd')
|
||||
local dOverlap = max( dOverlap1, dOverlap2)
|
||||
local dLen = EgtCurveLength( nLinkId)
|
||||
|
||||
-- porto il link nel gruppo locale
|
||||
local nLinkLoc = EgtCopyGlob( nLinkId, nGrpTmp)
|
||||
-- verifico che non entri nella tavola
|
||||
local b3Box = EgtGetBBoxGlob( nLinkId, GDB_BB.STANDARD)
|
||||
if b3Box:getMin():getZ() < - GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
|
||||
-- eventuale verifica con setti coinvolti dal link
|
||||
-- verifico non passi per estremo errato
|
||||
if nCurr ~= nNext then
|
||||
local dParTest1 = EgtCurveParamAtPoint( nLinkId, EgtSP( nCurr, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
local dParTest2 = EgtCurveParamAtPoint( nLinkId, EgtEP( nNext, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParTest1 or dParTest2 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
if bCheckLinked and dLen > 3 * dStrand then
|
||||
-- regione occupata dai setti
|
||||
local nSrfRibs = EgtSurfFrFatCurve( nGrpTmp, nCurr, dStrand, false) or GDB_ID.NULL
|
||||
local nSrfRibs2 = EgtSurfFrFatCurve( nGrpTmp, nNext, dStrand, false) or GDB_ID.NULL
|
||||
EgtSurfFrAdd( nSrfRibs, nSrfRibs2)
|
||||
-- verifico che i tratti fuori abbiano lunghezza maggiore di quelli dentro
|
||||
local nLinkLoc = EgtCopyGlob( nLinkId, nGrpTmp)
|
||||
local nRes, nCnt = EgtTrimCurveWithRegion( nLinkLoc, nSrfRibs, false, false)
|
||||
if nCnt == 0 then return false end
|
||||
local dResLen = EgtCurveLength( nRes)
|
||||
if dResLen < ( dLen - dResLen) - GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se interseca altri setti ( considerando anche le tipologie del PathGrp non ancora realizzate)
|
||||
local nLinkLoc = EgtCopyGlob( nLinkId, nGrpTmp)
|
||||
local nOrigCurr = EgtGetInfo( nCurr, KEY_ORIGINAL_RIB, 'i')
|
||||
local nOrigNext = EgtGetInfo( nNext, KEY_ORIGINAL_RIB, 'i')
|
||||
local vRibsIds = EgtGetNameInGroup( EgtGetParent( nCurr), RIBS_CRV .. '*')
|
||||
@@ -1067,28 +1105,6 @@ local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
end
|
||||
end
|
||||
|
||||
-- eventuale verifica con setti coinvolti dal link ( da fare solo se collegamento fra passate di setti diversi)
|
||||
if bCheckLinked and dLen > 3 * dStrand then
|
||||
-- regione occupata dai setti
|
||||
local nSrfRibs = EgtSurfFrFatCurve( nGrpTmp, nCurr, dStrand, false) or GDB_ID.NULL
|
||||
local nSrfRibs2 = EgtSurfFrFatCurve( nGrpTmp, nNext, dStrand, false) or GDB_ID.NULL
|
||||
EgtSurfFrAdd( nSrfRibs, nSrfRibs2)
|
||||
-- verifico che i tratti fuori abbiano lunghezza maggiore di quelli dentro
|
||||
local nRes, nCnt = EgtTrimCurveWithRegion( nLinkLoc, nSrfRibs, false, false)
|
||||
if nCnt == 0 then return false end
|
||||
local dResLen = EgtCurveLength( nRes)
|
||||
if dResLen < ( dLen - dResLen) - GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
|
||||
-- verifico non passi per estremo errato
|
||||
local dParTest1 = EgtCurveParamAtPoint( nLinkId, EgtSP( nCurr, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
local dParTest2 = EgtCurveParamAtPoint( nLinkId, EgtEP( nNext, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParTest1 or dParTest2 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se si trova almeno in una regione ammissibile ( per caso ForcedLink)
|
||||
local nType = EgtGetInfo( nCurr, KEY_RIBS_TYPE, 'i')
|
||||
local nOut = 0
|
||||
@@ -1117,24 +1133,68 @@ local function VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeRibsLinkOnDiffCrvs( nCrvS, nCrvE, dParS, dParE)
|
||||
local function ComputeRibsLinkOnSameCrv( nCrvId, dParS, dParE, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
|
||||
-- recupero il tratto interessato sulla curva1
|
||||
local _, _, dParFinal = EgtPointCurveDist( EgtUP( nCrvE, dParE, GDB_ID.ROOT), nCrvS, GDB_ID.ROOT)
|
||||
local nCrv1 = ComputeShortestCrv( nCrvS, dParS, dParFinal)
|
||||
local nParentId = EgtGetParent( nCrvId)
|
||||
|
||||
-- recupero il tratto interessato sulla cruva2
|
||||
local _, _, dParStart = EgtPointCurveDist( EgtUP( nCrvS, dParS, GDB_ID.ROOT), nCrvE, GDB_ID.ROOT)
|
||||
local nCrv2 = ComputeShortestCrv( nCrvE, dParStart, dParE)
|
||||
|
||||
-- modifico nCrv2 per avere una transizione uniforme da nCrv1
|
||||
if EgtSpiralizeCurveAlongGuide( nCrv2, nCrv1) then
|
||||
EgtErase( nCrv1)
|
||||
return nCrv2
|
||||
-- verifico il percorso dParS->dParE
|
||||
local nCopyId = EgtCopyGlob( nCrvId, nParentId, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId, dParS, dParE)
|
||||
if VerifyRibsLink( nCopyId, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked) then
|
||||
return nCopyId
|
||||
else
|
||||
EgtErase( nCrv1)
|
||||
-- se non valido tento con il percorso dParE->dParS
|
||||
EgtErase( nCopyId)
|
||||
nCopyId = EgtCopyGlob( nCrvId, nParentId, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId, dParE, dParS)
|
||||
EgtInvertCurve( nCopyId)
|
||||
if VerifyRibsLink( nCopyId, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked) then
|
||||
return nCopyId
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ComputeRibsLinkOnDiffCrvs( nCrvS, nCrvE, dParS, dParE, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
|
||||
local nParentId = EgtGetParent( nCrvS)
|
||||
|
||||
local _, _, dParFinal = EgtPointCurveDist( EgtUP( nCrvE, dParE, GDB_ID.ROOT), nCrvS, GDB_ID.ROOT)
|
||||
local _, _, dParStart = EgtPointCurveDist( EgtUP( nCrvS, dParS, GDB_ID.ROOT), nCrvE, GDB_ID.ROOT)
|
||||
|
||||
-- tento con il tratto dParS->dParE
|
||||
-- recupero il tratto interessato sulla curva1
|
||||
local nCrv1 = EgtCopyGlob( nCrvS, nParentId, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCrv1, dParS, dParFinal)
|
||||
-- recupero il tratto interessato sulla curva2
|
||||
local nCrv2 = EgtCopyGlob( nCrvE, nParentId, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCrv2, dParStart, dParE)
|
||||
-- modifico nCrv2 per avere una transizione uniforme da nCrv1
|
||||
EgtSpiralizeCurveAlongGuide( nCrv2, nCrv1)
|
||||
EgtErase( nCrv1)
|
||||
-- verifico se valida
|
||||
if VerifyRibsLink( nCrv2, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked) then
|
||||
return nCrv2
|
||||
|
||||
else
|
||||
-- tento con il tratto dParE->dParS
|
||||
EgtErase( nCrv2)
|
||||
return nil
|
||||
nCrv1 = EgtCopyGlob( nCrvS, nParentId, GDB_IN.AFTER) -- tratto interessato sulla curva1
|
||||
EgtTrimCurveStartEndAtParam( nCrv1, dParFinal, dParS)
|
||||
EgtInvertCurve( nCrv1)
|
||||
nCrv2 = EgtCopyGlob( nCrvE, nParentId, GDB_IN.AFTER) -- tratto interessato sulla curva2
|
||||
EgtTrimCurveStartEndAtParam( nCrv2, dParE, dParStart)
|
||||
EgtInvertCurve( nCrv2)
|
||||
EgtSpiralizeCurveAlongGuide( nCrv2, nCrv1) -- transizione uniforme da nCrv1
|
||||
EgtErase( nCrv1)
|
||||
if VerifyRibsLink( nCrv2, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked) then
|
||||
return nCrv2
|
||||
else
|
||||
EgtErase( nCrv2)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1172,10 +1232,10 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink, bCheckLinked, v
|
||||
local nLinkId
|
||||
if vIdsS[i] == vIdsE[j] then
|
||||
-- link su una sola curva
|
||||
nLinkId = ComputeShortestCrv( vCrvIds[vIdsS[i]], vParS[i], vParE[j])
|
||||
nLinkId = ComputeRibsLinkOnSameCrv( vCrvIds[vIdsS[i]], vParS[i], vParE[j], nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
else
|
||||
-- link tra due curve distinte
|
||||
nLinkId = ComputeRibsLinkOnDiffCrvs( vCrvIds[vIdsS[i]], vCrvIds[vIdsE[j]], vParS[i], vParE[j])
|
||||
nLinkId = ComputeRibsLinkOnDiffCrvs( vCrvIds[vIdsS[i]], vCrvIds[vIdsE[j]], vParS[i], vParE[j], nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
end
|
||||
|
||||
if nLinkId then
|
||||
@@ -1184,13 +1244,7 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink, bCheckLinked, v
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLinkId, KEY_CRV_STRAND, dStrand)
|
||||
-- verifico se valido
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
if bValid then
|
||||
return nLinkId
|
||||
else
|
||||
EgtErase( nLinkId)
|
||||
end
|
||||
return nLinkId
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1203,7 +1257,7 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink, bCheckLinked, v
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.AFTER)
|
||||
EgtSetInfo( nLinkId, KEY_CRV_STRAND, dStrand)
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, bCheckLinked)
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, dStrand, bCheckLinked)
|
||||
if bValid then
|
||||
return nLinkId
|
||||
else
|
||||
@@ -1215,6 +1269,38 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, bForceLink, bCheckLinked, v
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcLoopRibLink( nCurr, nNext, nLoopGrp, vtSlicing, nGrpTmp)
|
||||
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
if AreSamePointApprox( ptS, ptE) then return end
|
||||
local dStrand = EgtGetInfo( nCurr, KEY_CRV_STRAND, 'd')
|
||||
|
||||
local vCrvIds = EgtGetAllInGroup( nLoopGrp)
|
||||
-- scorro le curve di bordo e verifico se posso creare il link
|
||||
for i = 1, #vCrvIds do
|
||||
local dParS = EgtCurveParamAtPoint( vCrvIds[i], ptS, 10 * GEO.EPS_SMALL)
|
||||
local dParE = EgtCurveParamAtPoint( vCrvIds[i], ptE, 10 * GEO.EPS_SMALL)
|
||||
if dParS and dParE then
|
||||
local nLinkId = ComputeShortestCrv( vCrvIds[i], dParS, dParE)
|
||||
if nLinkId then
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.AFTER)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLinkId, KEY_CRV_STRAND, dStrand)
|
||||
if VerifyRibsLink( nLinkId, nCurr, nNext, nGrpTmp, dStrand, false) then
|
||||
return nLinkId
|
||||
else
|
||||
EgtErase( nLinkId)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLead( nId, nRibId, bInVsOut, nGrpTmp)
|
||||
|
||||
@@ -1623,13 +1709,16 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
local bCheckLinkedRibs = not bForceLink and not bUserLink
|
||||
|
||||
if ( nOrig1 ~= nOrig2 and bUserLink) or ( nSplitId1 == nSplitId2 and nOrig1 == nOrig2) then
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, bForceLink, bCheckLinkedRibs, LayerParams.vtSlicing, nGrpTmp)
|
||||
|
||||
-- se LoopRib congiungo i setti in unico percorso
|
||||
if bLoopRib and nLinkId then
|
||||
EgtAddCurveCompoCurve( tabRibs[i][j], nLinkId)
|
||||
EgtAddCurveCompoCurve( tabRibs[i][j], tabRibs[i][j + 1])
|
||||
tabRibs[i][j+1] = tabRibs[i][j] -- aggiorno id nel vettore dei setti per gestire correttamente la curva allo step successivo
|
||||
if not bLoopRib then
|
||||
CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, bForceLink, bCheckLinkedRibs, LayerParams.vtSlicing, nGrpTmp)
|
||||
else
|
||||
local nLinkId = CalcLoopRibLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, LayerParams.vtSlicing, nGrpTmp)
|
||||
-- se collegamento congiungo i setti in unico percorso
|
||||
if nLinkId then
|
||||
EgtAddCurveCompoCurve( tabRibs[i][j], nLinkId)
|
||||
EgtAddCurveCompoCurve( tabRibs[i][j], tabRibs[i][j + 1])
|
||||
tabRibs[i][j+1] = tabRibs[i][j] -- aggiorno id nel vettore dei setti per gestire correttamente la curva allo step successivo
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1637,7 +1726,7 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
-- se LoopRib aggiungo collegamento tra primo e ultimo setto del gruppo
|
||||
if bLoopRib then
|
||||
local nTotCrv = #tabRibs[i]
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][nTotCrv], tabRibs[i][1], nLoopGrp, false, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
local nLinkId = CalcLoopRibLink( tabRibs[i][nTotCrv], tabRibs[i][1], nLoopGrp, LayerParams.vtSlicing, nGrpTmp)
|
||||
if nLinkId then
|
||||
-- se curva unica
|
||||
if tabRibs[i][nTotCrv] == tabRibs[i][1] then
|
||||
@@ -1668,7 +1757,9 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
for i = 1, #tabRibs - 1 do
|
||||
local bLink1 = EgtGetInfo( tabRibs[i][1], KEY_RIBS_LINK, 'b')
|
||||
local bLink2 = EgtGetInfo( tabRibs[i + 1][1], KEY_RIBS_LINK, 'b')
|
||||
if bLink1 and bLink2 then
|
||||
local bLoop1 = EgtGetInfo( tabRibs[i][1], KEY_LOOP_RIB, 'b') or false
|
||||
local bLoop2 = EgtGetInfo( tabRibs[i + 1][1], KEY_LOOP_RIB, 'b') or false
|
||||
if bLink1 and bLink2 and not bLoop1 and not bLoop2 then
|
||||
local nCnt = #tabRibs[i]
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, false, true, LayerParams.vtSlicing, nGrpTmp)
|
||||
end
|
||||
@@ -1875,7 +1966,7 @@ function CalcToolPath.Exec( nPartId)
|
||||
end
|
||||
|
||||
local b3Tot = BBox3d() -- box dei toolpath
|
||||
|
||||
local nLayCnt = 1
|
||||
-- Ciclo sui layer
|
||||
for nIdx = 1, #vLayIds do
|
||||
|
||||
@@ -1958,6 +2049,11 @@ function CalcToolPath.Exec( nPartId)
|
||||
local b3Box = ComputeToolPathBox( nTpathGrpId)
|
||||
b3Tot:Add( b3Box)
|
||||
|
||||
-- verifico non sia vuoto per aggiornare il numero di layers
|
||||
if EgtGetFirstInGroup( nTpathGrpId) then
|
||||
nLayCnt = nIdx
|
||||
end
|
||||
|
||||
-- passo al gruppo di contorni successivo
|
||||
nCrvGrpId = EgtGetNextName( nCrvGrpId, CONTOUR_GRP.."*")
|
||||
end
|
||||
@@ -1971,6 +2067,9 @@ function CalcToolPath.Exec( nPartId)
|
||||
-- correzione in z
|
||||
AddZCorrection( b3Tot, LayerParams)
|
||||
|
||||
-- setto info con numero di layers effettivi
|
||||
EgtSetInfo( nPartId, KEY_LAYER_CNT, nLayCnt)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -157,10 +157,6 @@ function RunSlicing.Exec()
|
||||
EgtRemoveAllOperations()
|
||||
EgtResetCurrMachGroup()
|
||||
|
||||
-- Lettura dati macchina
|
||||
local sMachIni = EgtGetCurrMachineDir() .. '\\' .. EgtGetCurrMachineName() .. '.ini'
|
||||
local HMax = tonumber( EgtGetStringFromIni( '3dPrinting', 'HMax', 500, sMachIni))
|
||||
|
||||
-- Eventuale ripristino posizione originaria
|
||||
RestoreOriginalPosition( nPartId)
|
||||
|
||||
@@ -171,7 +167,7 @@ function RunSlicing.Exec()
|
||||
RemoveOldTFS()
|
||||
|
||||
-- Calcolo delle fette
|
||||
local bOk = CSLICES.Exec( nPartId, nStmId, HMax)
|
||||
local bOk = CSLICES.Exec( nPartId, nStmId)
|
||||
EgtDraw()
|
||||
|
||||
-- Calcolo dei percorsi sul centro strand in basso
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
-- Version.lua by Egaltech s.r.l. 2023/02/28
|
||||
-- Version.lua by Egaltech s.r.l. 2023/08/28
|
||||
-- Gestione della versione di 3dPrinting
|
||||
|
||||
VERSION = '2.5g1'
|
||||
VERSION = '2.5h1'
|
||||
Reference in New Issue
Block a user