Files
datadoors/LuaLibs/_MortiseCorner.lua
Dario Sassi cc55202ec5 DataDoors 2.7c1 :
- primo commit con versione corrente.
2025-03-18 17:02:20 +01:00

955 lines
43 KiB
Lua

--
-- EEEEEEEEEE GGGGGG wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwww wwww
-- EEEE GGGG GGGG wwww wwww wwww
-- EEEE GGGG wwww wwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEE GGGG GGGG wwww wwwwwwww wwww
-- EEEE GGGG GGGG wwww wwww wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww
-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww
--
-- _MortiseCorner.lua by EgalWare s.r.l. 2016.06.14
-- Autore: Filippo Monchi
-- Mortise, componente di secondo livello, non può essere chiamato direttamente da un lua dei
-- componenti di interfaccia
-- 2019.10.18 V2.000 FM Manage use Materials
-- 2024.07.19 V2.001 FM Set note 'NotCheckDir' to pocketing paths
-- Tavola per definizione modulo (serve ma non usata)
local _MortiseCorner = {}
-- Intestazioni
require( 'EgtBase')
EgtEnableDebug( false)
-- per messaggi
-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua')
-- Valori limite
local dExtraH = 0.5
local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2)
local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC)
if idTable then
table.insert( idTable, nLine)
end
if bPrev then
if bDrawFirst then
local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC)
EgtSetColor(nCircle1, cColor1)
end
if bDrawLast then
local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC)
EgtSetColor(nCircle2, cColor2)
end
end
return nLine
end
-- Funzione di disegno
function _MortiseCorner.Draw( EC, EM, tMortiseParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor)
-- Assegno le dimensioni
local T = tMortiseParam.T
local L2 = tMortiseParam.L2
local H2 = tMortiseParam.H2
local T2 = tMortiseParam.T2
local s = tMortiseParam.s
local d = tMortiseParam.d
local p = tMortiseParam.p
local jn = tMortiseParam.jn
local d2 = tMortiseParam.d3
local p2 = tMortiseParam.p3
local invG = tMortiseParam.invG
local mkrev = tMortiseParam.mkrev
local jne = tMortiseParam.jne
local L3 = tMortiseParam.L3
local H3 = tMortiseParam.H3
local D_X = tMortiseParam.D_X
local pbs = tMortiseParam.pbs
-- Assegno i nomi dei layer
local LGM = tMortiseParam.LGM
local LMM = tMortiseParam.LMM
local DM = 'DUMMY'
-- variabili per messaggi e settaggi vari
local sCompoName = tMortiseParam.Nome
-- RunByComponetInterface
local RC = true
-- Variabili per risalita distaccata
local nDeltaMovX = 2
local nDeltaMovY = 2
if not bRunByCompo then
RC = false
end
if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione
nDrawMach = 0
end
-- Layer
local Dm
if not Lg then
Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale
EgtSetName(Lg,sCompoName)
end
if nDrawMach > 0 then -- se abilitata geometria lavorazione
Dm = EgtGroup(Pz,GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile
EgtSetName(Dm,DM)
end
local hint1, hint2, hint3, hint4, hint5
local hint_2, hintPk2, hintPk2_r
if nDrawMach ~= 1 then -- se abilitata geometria esterna
-- Costruzione della geometria cerniera secondaria
hint1 = DrawAddLineDrawCircle( Point3d(-L2/2,0,0), Point3d(-L2/2,H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint2 = DrawAddLineDrawCircle( Point3d(-L2/2,H2/2,0), Point3d(L2/2,H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint3 = DrawAddLineDrawCircle( Point3d(L2/2,H2/2,0), Point3d(L2/2,-H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint4 = DrawAddLineDrawCircle( Point3d(L2/2,-H2/2,0), Point3d(-L2/2,-H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint5 = DrawAddLineDrawCircle( Point3d(-L2/2,-H2/2,0), Point3d(-L2/2,0,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED())
hint_2 = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true)
EgtModifyCurveThickness(hint_2, -T2)
EgtSetName(hint_2,LGM)
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hint_2, 'ProbeSide', '1')
end
end
---------------------------------------
---------------------------------------
-- Costruzione delle geometrie di lavorazione
---------------------------------------
---------------------------------------
if nDrawMach > 0 then -- se abilitata geometria lavorazione
if not Lg then
Lg = EgtGroup(Pz,GDB_RT.LOC)
EgtSetName(Lg,sCompoName)
end
local tPocket2 = {}
local tPocket2_r = {}
local pIni, pEnd
local pIni_r, pEnd_r
local pEnd2, pEnd2_r
local nCase
local nCaseNext
local dZedStart
local dZedWork
---------------------------------------
-- geometria svuotatura giro interno
---------------------------------------
local nStep
local dStep
local dPerim
local nDirVers
local nPass
if jn then -- svuotature unite calcolo il numero di passi in Z
-- individuo in che caso sono
if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro
nCase = 1
elseif (H2-d) <= ( d*0.98) then -- solo passaggio di contornatura
nCase = 2
elseif ((H2-d) > ( d*0.98)) and ( (H2-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale
nCase = 3
elseif (H2-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag
nCase = 4
end
dPerim = 2*( H2 + L2 -(d*3/2))+(d*3/2)
nStep = ceil((T2-T)/s) -- numero di passate
dStep = ((T2-T)/nStep) -- passo ricalcolato
dZedStart = -T
else -- svuotature separate ricalcolo i casi e il numero di passi in Z
-- individuo in che caso sono
if abs(H2-d2) < 0.03 then -- solo 1 passaggio in centro
nCase = 1
elseif (H2-d2) <= ( d2*0.98) then -- solo passaggio di contornatura
nCase = 2
elseif ((H2-d2) > ( d2*0.98)) and ( (H2-d2) <= (d2*(1+p2))) then -- passaggio di contornatura + un passaggio centrale
nCase = 3
elseif (H2-d2) > (d2*(1+p2)) then -- passaggio di contornatura + passaggi zig zag
nCase = 4
end
dPerim = 2*( H2 + L2 -(d2*3/2))+(d2*3/2)
nStep = ceil(T2/s) -- numero di passate
dStep = (T2/nStep) -- passo ricalcolato
dZedStart = 0
end
if jn then -- svuotature unite
if nCase == 1 then -- solo 1 passaggio in centro
nPass = 1
pEnd = Point3d(((L2-d)/2),0,dZedStart)
if mkrev then -- se abilitato anche il percorso inverso
pEnd_r = Point3d(((L2-d)/2),0,dZedStart)
end
while nPass <= nStep do
-- primo mezzo passo
pIni = pEnd
dZedWork = dZedStart - (dStep * ( nPass - 0.5))
pEnd = Point3d(-((L2/2)+dExtraH),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+dExtraH),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- secondo mezzo passo
pIni = pEnd
dZedWork = dZedStart - (dStep * nPass)
if nPass == nStep then
dZedWork = -T2
end
pEnd = Point3d(((L2-d)/2),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d)/2),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
nPass = nPass + 1
end
-- ultimo mezzo passo
pIni = pEnd
dZedWork = -T2
pEnd = Point3d(-((L2/2)+dExtraH),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+dExtraH),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
pIni = pEnd
-- Uscita in Z0
dZedWork = 0
pEnd = Point3d((-((L2/2)+dExtraH)-nDeltaMovX),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-((L2/2)+dExtraH)-nDeltaMovX),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
end
-- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura
elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then
nPass = 1
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedStart)
if mkrev then -- se abilitato anche il percorso inverso
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedStart)
end
while nPass <= nStep do
if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo
-- prima linea discendente
pIni = pEnd
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T2
end
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
-- prima linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((L2-(d/2)+(d*3/4))/dPerim))
end
pEnd = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- seconda linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((H2+L2-(d*3/2)+(d*3/4))/dPerim))
end
pEnd = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- terza linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*(((2*L2)+H2-(2*d)+(2*(d*3/4)))/dPerim))
end
pEnd = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- quarta linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T2
end
end
if nCase == 3 then
pEnd = Point3d(-((L2/2)+(d*3/4)),0,dZedWork)
elseif nCase == 4 then
pEnd = Point3d(-((L2/2)+(d*3/4)),(((H2-d)/2)-(d2*p))*invG,dZedWork)
else
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
end
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
if nCase == 3 then
pEnd_r = Point3d(-((L2/2)+(d*3/4)),0,dZedWork)
elseif nCase == 4 then
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-(((H2-d)/2)-(d2*p))*invG,dZedWork)
else
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
end
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno
if nCase == 2 and nPass == nStep then -- passaggio di contornatura
pIni = pEnd
pEnd = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- seconda linea contorno
pIni = pEnd
pEnd = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- terza linea contorno
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- quarta linea contorno
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d)/2
end
pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
if nCase == 3 then -- passaggio di contornatura + un passaggio centrale
-- quinta linea passata centrale
pIni = pEnd
pEnd = Point3d((((L2*2)-(d*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((((L2*2)-(d*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME())
end
-- sesta linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d)/2
end
pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura
nDirVers = 1
local nDistYcentr = (d*p)
local nPosYcentr = ((H2-d)/2) - nDistYcentr
local bContinue = nPosYcentr > -((H2-d)/2)
local dXVal
local bNotFirst = false
-- linea posizionamento passaggi svuotatura
pIni = pEnd
pEnd = Point3d((-nDirVers * ((L2/2)+(d*3/4))),nPosYcentr*invG,dZedWork)
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-nDirVers * ((L2/2)+(d*3/4))),-nPosYcentr*invG,dZedWork)
end
-- ciclo passate svuotatura
while bContinue do
if bNotFirst then -- non faccio il primo posizionamento perchè già posizionato nel giro esterno
-- linea affondamento in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
if mkrev then -- se abilitato anche il percorso inverso
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
end
else
bNotFirst = true
end
-- linea passata in X
pIni = pEnd
if nDirVers > 0 then
dXVal = (((L2*2)-(d*3))/4)
else
dXVal = ((L2/2)+(d*3/4))
end
pEnd = Point3d((nDirVers * dXVal),nPosYcentr*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((nDirVers * dXVal),-nPosYcentr*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
end
-- calcolo nuovo passo in Y e indice direzione
nPosYcentr = nPosYcentr - nDistYcentr
bContinue = nPosYcentr > -((H2-d)/2)
-- calcolo prossimo punto solo se sono ancora dentro l'area
if bContinue then
-- ricalcolo punti per linea successiva
pIni = pEnd
if nDirVers > 0 then
dXVal = (((L2*2)-(d*3))/4)
else
dXVal = ((L2/2)+(d*3/4))
end
nDirVers = -nDirVers
pEnd = Point3d((-nDirVers * dXVal),nPosYcentr*invG,dZedWork)
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-nDirVers * dXVal),-nPosYcentr*invG,dZedWork)
end
end
end
-- ultima linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d)/2
end
pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
nPass = nPass + 1
dZedStart = dZedStart - dStep
end
pIni = pEnd
-- Uscita in Z0
DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
end
end
else -- svuotature separate
if nCase == 1 then -- solo 1 passaggio in centro
nPass = 1
dZedStart = 0
pEnd = Point3d(((L2-d2)/2),0,dZedStart) -- nuovo punto finale
hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC)
EgtSetColor(hint3,PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pEnd_r = Point3d(((L2-d2)/2),0,dZedStart) -- nuovo punto finale
end
while nPass <= nStep do
-- primo mezzo passo
pIni = pEnd
dZedWork = dZedStart - (dStep * ( nPass - 0.5))
pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- secondo mezzo passo
pIni = pEnd
dZedWork = dZedStart - (dStep * nPass)
if nPass == nStep then
dZedWork = -T2
end
pEnd = Point3d(((L2-d2)/2),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d2)/2),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
nPass = nPass + 1
end
-- ultimo mezzo passo
pIni = pEnd
dZedWork = -T2
pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
pIni = pEnd
-- Uscita in Z0
dZedWork = 0
pEnd = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
end
-- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura
elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then
nPass = 1
dZedStart = 0
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedStart) -- nuovo punto finale
hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC)
EgtSetColor(hint3,PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedStart) -- nuovo punto finale
end
while nPass <= nStep do
if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo
-- prima linea discendente
pIni = pEnd
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T2
end
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
-- prima linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((L2-(d2/2)+(d2*3/4))/dPerim))
end
pEnd = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- seconda linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*((H2+L2-(d2*3/2)+(d2*3/4))/dPerim))
end
pEnd = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- terza linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - ( dStep*(((2*L2)+H2-(2*d2)+(2*(d2*3/4)))/dPerim))
end
pEnd = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- quarta linea contorno
pIni = pEnd
if nCase == 2 then
dZedWork = dZedStart - dStep
if nPass == nStep then
dZedWork = -T2
end
end
if nCase == 3 then
pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
elseif nCase == 4 then
pEnd = Point3d(-((L2/2)+(d2*3/4)),(((H2-d2)/2)-(d2*p))*invG,dZedWork)
else
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
end
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
if nCase == 3 then
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork)
elseif nCase == 4 then
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-(((H2-d2)/2)-(d2*p))*invG,dZedWork)
else
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
end
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno
if nCase == 2 and nPass == nStep then -- passaggio di contornatura
-- prima linea contorno
pIni = pEnd
pEnd = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- seconda linea contorno
pIni = pEnd
pEnd = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- terza linea contorno
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
-- quarta linea contorno
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d2)/2
end
pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
if nCase == 3 then -- passaggio di contornatura + un passaggio centrale
-- quinta linea passata centrale
pIni = pEnd
pEnd = Point3d((((L2*2)-(d2*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((((L2*2)-(d2*3))/4),0,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME())
end
-- sesta linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d2)/2
end
pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura
nDirVers = 1
local nDistYcentr = (d2*p)
local nPosYcentr = ((H2-d2)/2) - nDistYcentr
local bContinue = nPosYcentr > -((H2-d2)/2)
local dXVal
local bNotFirst = false
-- linea posizionamento passaggi svuotatura
pIni = pEnd
pEnd = Point3d((-nDirVers * ((L2/2)+(d2*3/4))),nPosYcentr*invG,dZedWork)
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-nDirVers * ((L2/2)+(d2*3/4))),-nPosYcentr*invG,dZedWork)
end
-- ciclo passate svuotatura
while bContinue do
if bNotFirst then -- non faccio il primo posizionamento perchè già posizionato nel giro esterno
-- linea affondamento in Y
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW())
if mkrev then -- se abilitato anche il percorso inverso
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
end
else
bNotFirst = true
end
-- linea passata in X
pIni = pEnd
if nDirVers > 0 then
dXVal = (((L2*2)-(d2*3))/4)
else
dXVal = ((L2/2)+(d2*3/4))
end
pEnd = Point3d((nDirVers * dXVal),nPosYcentr*invG,dZedWork)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((nDirVers * dXVal),-nPosYcentr*invG,dZedWork)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW())
end
-- calcolo nuovo passo in Y e indice direzione
nPosYcentr = nPosYcentr - nDistYcentr
bContinue = nPosYcentr > -((H2-d2)/2)
-- calcolo prossimo punto solo se sono ancora dentro l'area
if bContinue then
-- ricalcolo punti per linea successiva
pIni = pEnd
if nDirVers > 0 then
dXVal = (((L2*2)-(d2*3))/4)
else
dXVal = ((L2/2)+(d2*3/4))
end
nDirVers = -nDirVers
pEnd = Point3d((-nDirVers * dXVal),nPosYcentr*invG,dZedWork)
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d((-nDirVers * dXVal),-nPosYcentr*invG,dZedWork)
end
end
end
-- ultima linea ritorno a posizione iniziale
pIni = pEnd
pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork)
if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y
nDeltaMovY = (H2-d2)/2
end
pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork)
pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0)
DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE())
end
end
nPass = nPass + 1
dZedStart = dZedStart - dStep
end
pIni = pEnd
-- Uscita in Z0
DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN())
if mkrev then -- se abilitato anche il percorso inverso
pIni_r = pEnd_r
DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN())
end
end
end
-- trasformo in geometria composita i/il percorsi/o di svuotatura
-- secondo percorso
if ( #tPocket2 > 0) then
hintPk2 = EgtCurveCompo( Lg, tPocket2, true)
if hintPk2 then
EgtModifyCurveThickness(hintPk2, 0)
EgtMove( hintPk2, Point3d(L2/2,0,0) - ORIG())
EgtSetName(hintPk2,LMM)
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintPk2, 'ProbeSide', '1')
end
end
end
if ( #tPocket2_r > 0) then
hintPk2_r = EgtCurveCompo( Lg, tPocket2_r, true)
if hintPk2_r then
EgtModifyCurveThickness(hintPk2_r, 0)
EgtMove( hintPk2_r, Point3d(L2/2,0,0) - ORIG())
EgtSetName(hintPk2_r,(LMM..'_R'))
if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then
EgtSetInfo( hintPk2_r, 'ProbeSide', '1')
end
end
end
end
if hint_2 then
EgtMove( hint_2, Point3d(L2/2,0,0) - ORIG())
end
-- cambio colore alla geometria
if bPreview then
if EC == 0 then
if hint_2 then
EgtSetColor(hint_2,AQUA())
end
if hintPk2 then
EgtSetColor(hintPk2,AQUA())
end
if hintPk2_r then
EgtSetColor(hintPk2_r,AQUA())
end
else
if hint_2 then
EgtSetColor(hint_2,ORANGE())
end
if hintPk2 then
EgtSetColor(hintPk2,ORANGE())
end
if hintPk2_r then
EgtSetColor(hintPk2_r,ORANGE())
end
end
else -- altrimenti non Preview
-- cancello le parti ausiliarie se disegnate
if Dm then
EgtErase( Dm)
end
-- assegno nota su percorsi svuotatura
if hintPk2 then
EgtSetInfo( hintPk2, 'NotCheckDir', '1')
end
if hintPk2_r then
EgtSetInfo( hintPk2_r, 'NotCheckDir', '1')
end
end
return hint_2, hintPk2, hintPk2_r
end
return _MortiseCorner