- aggiunta gestione della modifica delle paretine

- aggiunta la funzione per il clear della tabella globale
- resa pubblica la funzione per riempire la tabella dalle info di un part
- aggiunta la possibilità di scrivere un'info addizionale nelle paretine.
This commit is contained in:
Daniele Bariletti
2025-02-14 16:56:52 +01:00
parent 1d8bfba501
commit e6ed9a2ec6
+82 -28
View File
@@ -37,9 +37,7 @@ TOOL.dH = nil -- altezza della faccia buona della paretina corrente
TOOL.dTh = nil -- spessore del part corrente
TOOL.dThParent = nil -- spessore del parent
TOOL.dXOffset = nil -- offset del riferimento
-- TOOL.dBeta1 = nil
-- TOOL.dBeta2 = nil
TOOL.sName = nil -- nome del part corrente, incluso il codice univoco(es: sUNICode.."PartA1")
TOOL.sName = nil -- nome del part corrente, incluso il codice univoco(es: UUID.."PartA1")
TOOL.bPrev = nil -- booleano che indica se modificare anche la paretina successiva, in conseguenza delle modifica a quella corrente
TOOL.bNext = nil -- booleano che indica se modificare anche la paretina precedente, in conseguenza delle modifica a quella corrente
TOOL.UUID = nil -- output per la generazione di un nuovo UUID
@@ -48,13 +46,44 @@ TOOL.UUID = nil -- output per la generazione di un nuovo UUID
-- info addizionali che potrebbero esserci nella tbInfo
TOOL.tbInfo.nIn = nil -- intero che esiste solo se il part è stato costruito a partire da un edge di un InLoop e indica a quale degli InLoop(da contare in ordine all'interno del Parent, 1-based)
TOOL.tbInfo.bOutLoop = nil -- booleano che indica se l'edge su cui è stato costruito il part appartiene all'outloop o ad un inloop del Parent
TOOL.tbInfo.InfoKey = nil -- key dell'info da settare alla creazione del part
TOOL.tbInfo.InfoValue = nil -- valore della info da settare alla creazione del part
TOOL.tbIdLoop = {} -- tabella con gli id del loop su cui sta venendo costruita la paretina
---- creo il codice univoco per l'identificazione dei part
--TOOL.sUNICode = os.date( '%y%m%d%H%M%S', os.time()).."_"
-- enum per il tipo di junction
_G.JUNC = JUNC
JUNC = {TrimStart = 0, TrimEnd = 1, And = 3}
--local sUNICode = TOOL.sUNICode
function TOOL.ClearVariables()
TOOL.nId = nil
TOOL.nLayLoopParent = nil
TOOL.nLayLoop = nil
TOOL.nEdgeId = nil
TOOL.nEdge = nil
TOOL.tbInfo = {}
TOOL.nParent = nil
TOOL.nPrevId = nil
TOOL.nNextId = nil
TOOL.nPrev = nil
TOOL.nNext = nil
TOOL.dPairAng = nil
TOOL.nJunctionType = nil
TOOL.bOnLoop = nil
TOOL.dAngBR = nil
TOOL.dSideAngR = nil
TOOL.dAngBL = nil
TOOL.dSideAngL = nil
TOOL.dLen = nil
TOOL.dH = nil
TOOL.dTh = nil
TOOL.dThParent = nil
TOOL.dXOffset = nil
TOOL.sName = nil
TOOL.bPrev = nil
TOOL.bNext = nil
TOOL.UUID = nil
end
function TOOL.SaveMePlease()
EgtSaveFile('D:\\Temp\\marmo\\Vein3D\\FOO.nge')
@@ -105,7 +134,7 @@ local function FillInfoTable()
if TOOL.sName then TOOL.tbInfo.sName = TOOL.sName end
end
local function FillInfoTableFromPart(nPartId)
function TOOL.FillInfoTableFromPart(nPartId)
if not nPartId or nPartId == GDB_ID.NULL then return end
TOOL.tbInfo.nId = nPartId
TOOL.tbInfo.nPrevId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(nPartId,"Prev") or "") or GDB_ID.NULL
@@ -369,6 +398,11 @@ function TOOL.CreatePart(nLayLoop, tbPart, bIsPlanar)
end
if not tbPart then tbPart = TOOL.tbInfo end
-- setto eventualmente l'info addizionale
if tbPart.InfoKey and tbPart.InfoKey ~= "" then
EgtSetInfo(tbPart.nId, tbPart.InfoKey, tbPart.InfoValue)
end
-- recupero l'Id del part
local tbIdEntCrv = FindEdges(nLayLoop)
local IdPart = EgtGetParent( nLayLoop)
@@ -653,9 +687,6 @@ function CalcDraftAngle( vtDir1, vtDir2, dPairAng1, dPairAng2, dAngBetween)
local dSideAng = 0
dSideAng = (180 - dAng3d) / 2
--debug
EgtOutLog(EgtNumToString(dSideAng)..' '.. EgtNumToString(dBeta1).. ' '..EgtNumToString(dBeta2))
--debug
return dSideAng, dBeta1, dBeta2
end
@@ -872,6 +903,8 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
else
-- se ho una giunzione a T allora devo aggiustare la lunghezza dei pezzi sia che la faccia sia On, sia che sia Off
dLenPrev, dLen, _, dOffset = ManageJunction(PrevAng,dThPrev, dTh,tbInfo.nJunctionType, dLenPrev, dLen)
-- se sono su un inloop allora cambio il verso dell'offset
if tbInfo.nIn then dOffset = - dOffset end
-- setto il sideang da giunzione a T
local dSideAngDx = 90 - math.abs(PrevAng)
if tbInfo.bOnLoop then dSideAngDx = dSideAngDx * (-1) end
@@ -889,7 +922,8 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
if not tbInfo.bOnLoop then
local dOffset = dTh * tan( 90 - PrevAng)
dLen = dLen + dOffset
--if tbInfo.nJunctionType == 2 then dXOffset = dXOffset + dOffset end
-- se sono su un inloop allora cambio il verso dell'offset
if tbInfo.nIn then dOffset = - dOffset end
if tbInfo.nPairMode == 2 then dXOffset = dXOffset + dOffset end
end
end
@@ -913,6 +947,8 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
else
-- se ho una giunzione a T allora devo aggiustare la lunghezza dei pezzi sia che la faccia sia On, sia che sia Off
dLen, dLenNext, dXOffset, _ = ManageJunction(NextAng, dTh, dThNext, tbInfo.nJunctionType, dLen, dLenNext)
-- se sono su un inloop allora cambio il verso dell'offset
if tbInfo.nIn then dOffset = - dOffset end
-- setto il sideang da giunzione a T
local dSideAngSx = 90 - math.abs(NextAng)
if tbInfo.bOnLoop then dSideAngSx = dSideAngSx * (-1) end
@@ -930,7 +966,8 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
if not tbInfo.bOnLoop then
local dOffset = dTh * tan( 90 - NextAng)
dLen = dLen + dOffset
--if tbInfo.nJunctionType == 1 then dXOffset = dXOffset + dOffset end
-- se sono su un inloop allora cambio il verso dell'offset
if tbInfo.nIn then dOffset = - dOffset end
if tbInfo.nPairMode == 1 then dXOffset = dXOffset + dOffset end
end
end
@@ -953,15 +990,15 @@ local function ClearPart(nPartId)
ASS.Unpair()
ASS.bActiveHistory = true
-- cancello il solido
local PartSolid = EgtGetInfo(TOOL.tbInfo.nId, "Child")
local PartSolid = EgtGetInfo(nPartId, "Child")
EgtErase(PartSolid)
-- resetto l'id del part del solido
EgtSetInfo(nPartId, "Child", "")
-- cancello il riferimento nel part destinatario
local tbPairToRef = EgtGetInfo(nPartId, "PairToRef", "vs")
local nPartToRef = EgtGetFirstNameInGroup(GDB_ID.ROOT, tbPairToRef[1])
local tbLayers = TOOL.FindLayers(nPartToRef)
local nRef = EgtGetFirstNameInGroup(tbLayers["Ref"], tbPairToRef[2])
local nPartDest= EgtGetFirstNameInGroup(GDB_ID.ROOT, tbPairToRef[1])
local tbLayers = TOOL.FindLayers(nPartDest)
local nRef = EgtGetFirstNameInGroup(tbLayers["Ref"], tbPairToRef[2]) or GDB_ID.NULL
EgtErase(nRef)
end
@@ -973,6 +1010,7 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nNext)
local nChildPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "A"..tbInfo.nEdge))
if not nChildPart then
Pz_Bottom = TOOL.CreatePartLayer('BottomA'..EgtNumToString(i))
EgtSetInfo(Pz_Bottom, "Bottom", true)
tbInfo.sName = EgtGetName(Pz_Bottom)
EgtSetInfo(tbInfo.nParent, "A"..tbInfo.nEdge, tbInfo.sName)
tbInfo.nPrevId = nPrev or GDB_ID.NULL
@@ -991,11 +1029,19 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nNext)
else
-- se esisteva già ripulisco i layer della regione e del loop ed elimino il solido
ClearPart(nChildPart)
TOOL.tbInfo.nId = nChildPart
TOOL.tbInfo.sName = EgtGetName(TOOL.tbInfo.nId)
tbInfo.nId = nChildPart
tbInfo.nEdgeId = tbIdEdges[i]
tbInfo.sName = EgtGetName(tbInfo.nId)
tbInfo.dPairAng = 90 - TOOL.dSlopeAng
tbInfo.nPairSpin = -1
tbInfo.nJunctionType = 3
tbInfo.sDestRefOff = '0,0,-x'
tbInfo.sRefOff = '0,0,0'
tbInfo.bOnLoop = true
tbInfo.bInsideLoop = false
-- recupero l'id di eventuali vicini
TOOL.tbInfo.nPrevId = nPrev and nPrev or (EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(TOOL.tbInfo.nId, "Prev")) or GDB_ID.NULL)
TOOL.tbInfo.nNextId = nNext and nNext or (EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(TOOL.tbInfo.nId, "Next")) or GDB_ID.NULL)
tbInfo.nPrevId = (nPrev and nPrev ~= GDB_ID.NULL) and nPrev or (EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nId, "Prev")) or GDB_ID.NULL)
tbInfo.nNextId = (nNext and nNext ~= GDB_ID.NULL) and nNext or (EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nId, "Next")) or GDB_ID.NULL)
end
-- creo il fondo come paretina
local tbLayerBottom = TOOL.FindLayers(tbInfo.nId)
@@ -1121,6 +1167,10 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
tbInfo.dH = ((dOffsetMax - TOOL.dDiamBore/2) + dThParent) / cos(TOOL.dSlopeAng)
tbInfo.nEdge = 3 -- so già che il pezzo che creo si attaccherà al lato A3 del loop della paretina del lavandino
local nCurr = CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
-- aggiungo l'info addizionale, se presente
if tbInfo.InfoKey then
EgtSetInfo(tbInfo.nId, tbInfo.InfoKey, tbInfo.InfoValue)
end
if i == 1 then nFirst = nCurr end
if i == #tbIdEdges then tbInfo.nNextId = nFirst end
@@ -1130,11 +1180,11 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
local Next_i = i == #tbIdEdges and 1 or (i + 1)
if tbInfo.nPrevId and tbInfo.nPrevId ~= GDB_ID.NULL then
FillInfoTableFromPart(tbInfo.nPrevId)
TOOL.FillInfoTableFromPart(tbInfo.nPrevId)
CreateSplitBottomPart(tbInfo, Prev_i, tbIdEdges, nil, nCurr) -- da modificare gli input per il prev
end
if nNextId and nNextId ~= GDB_ID.NULL then
FillInfoTableFromPart(nNextId)
TOOL.FillInfoTableFromPart(nNextId)
CreateSplitBottomPart(tbInfo, Next_i, tbIdEdges, nCurr, nil) -- da modificare gli input per il next
end
@@ -1144,7 +1194,7 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
end
EgtErase(nAuxPart)
TOOL.ClearVariables()
end
local function CountInLoops(nEdgeId)
@@ -1300,13 +1350,13 @@ function TOOL.CreateParetinaFull(bPrev, bNext, bRecurs)
local sLayEdgeDest = EgtGetName(EgtGetParent(TOOL.tbInfo.nEdgeId))
if TOOL.tbInfo.bOnLoop then
-- waterfall
TOOL.tbInfo.dSideAngT = TOOL.dPairAng + 90
TOOL.tbInfo.dSideAngT = TOOL.tbInfo.dPairAng + 90
TOOL.tbInfo.dYOffset = TOOL.tbInfo.dTh * tan(TOOL.tbInfo.dSideAngT)
TOOL.tbInfo.sDestRefOff = '0,0,-x'
TOOL.tbInfo.sRefOff = '0,'..EgtNumToString(TOOL.tbInfo.dYOffset)..',0'
else
-- splashtop
TOOL.tbInfo.dSideAngT = TOOL.dPairAng - 90
TOOL.tbInfo.dSideAngT = TOOL.tbInfo.dPairAng - 90
TOOL.tbInfo.dYOffset = TOOL.tbInfo.dTh * tan(TOOL.tbInfo.dSideAngT)
TOOL.tbInfo.sDestRefOff = '0,0,0'
TOOL.tbInfo.sRefOff = EgtNumToString(TOOL.tbInfo.dXOffset)..','..EgtNumToString(TOOL.tbInfo.dYOffset)..',-x'
@@ -1332,18 +1382,22 @@ function TOOL.CreateParetinaFull(bPrev, bNext, bRecurs)
local nNextId = TOOL.tbInfo.nNextId
if bPrev and TOOL.tbInfo.nPrevId and TOOL.tbInfo.nPrevId ~= GDB_ID.NULL then
FillInfoTableFromPart(TOOL.tbInfo.nPrevId)
TOOL.FillInfoTableFromPart(TOOL.tbInfo.nPrevId)
TOOL.CreateParetinaFull(false, false, true)
end
-- modifico anche la paretina successiva(se esiste)
if bNext and nNextId and nNextId ~= GDB_ID.NULL then
FillInfoTableFromPart(nNextId)
TOOL.FillInfoTableFromPart(nNextId)
TOOL.CreateParetinaFull(false, false, true)
end
TOOL.SaveMePlease()
-- pulisco la tabella con i dati
TOOL.tbInfo = {}
if bRecurs then
TOOL.tbInfo = {}
else
TOOL.ClearVariables()
end
end
return TOOL