- correzione al set dei side ang
- correzione al recupero del PairAng dei vicni - correzione alla verifica dei vicini dello stesso tipo - completata la funzione clear part - resa ricorsiva la creazione dei pezzi in CreateSplitBottom.
This commit is contained in:
+63
-63
@@ -792,8 +792,8 @@ function TOOL.CreateAdjustedPart( tbInfo, dLenCorr)
|
||||
TOOL.SetMachiningInfo(nLayOutloop)
|
||||
|
||||
-- setto le info dei side ang
|
||||
if tbInfo.dSideAngL then TOOL.SetSideAng(tbInfo.nLayLoop, 'A2', tbInfo.dSideAngL) end
|
||||
if tbInfo.dSideAngR then TOOL.SetSideAng(tbInfo.nLayLoop, 'A4', tbInfo.dSideAngR) end
|
||||
if tbInfo.dSideAngL then TOOL.SetSideAng(tbInfo.nLayLoop, 'A2', tbInfo.dSideAngR) end
|
||||
if tbInfo.dSideAngR then TOOL.SetSideAng(tbInfo.nLayLoop, 'A4', tbInfo.dSideAngL) end
|
||||
return {nLine1, nLine2, nLine3, nLine4}
|
||||
end
|
||||
|
||||
@@ -812,7 +812,6 @@ function TOOL.CreateCircularHole(nPart, ptCenter, dDiam)
|
||||
TOOL.AddInLoopToPart(nInLoopLay)
|
||||
end
|
||||
|
||||
|
||||
function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
local tbIdLoopTC = {}
|
||||
-- se ho chiamato la funzione senza passare direttamente gli argomenti li recupero dalla tabella principale
|
||||
@@ -835,10 +834,10 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
local nNext = i < #tbIdLoopTC and i + 1 or 1
|
||||
if not tbInfo.nPrevId then tbInfo.nPrevId = GDB_ID.NULL end
|
||||
local dPairAng = (tbInfo.dPairAng or 0)
|
||||
local dPairAngPrev = (EgtGetInfo(tbInfo.nPrevId, 'PairAng', 'd') or dPairAng) + dPairAngCorr
|
||||
if not tbInfo.nNextId then tbInfo.nNextId = GDB_ID.NULL end
|
||||
local dPairAngNext = (EgtGetInfo(tbInfo.nNextId, 'PairAng', 'd') or dPairAng) + dPairAngCorr
|
||||
dPairAng = dPairAng + dPairAngCorr
|
||||
local dPairAngPrev = (EgtGetInfo(tbInfo.nPrevId, 'PairAng', 'd') or 0) + dPairAngCorr
|
||||
if not tbInfo.nNextId then tbInfo.nNextId = GDB_ID.NULL end
|
||||
local dPairAngNext = (EgtGetInfo(tbInfo.nNextId, 'PairAng', 'd') or 0) + dPairAngCorr
|
||||
local vtDirCurr = EgtSV( tbIdLoopTC[i], GDB_RT.GLOB)
|
||||
local vtDirNext = EgtSV( tbIdLoopTC[nNext], GDB_RT.GLOB)
|
||||
local vtDirPrev = EgtEV( tbIdLoopTC[nPrev], GDB_RT.GLOB)
|
||||
@@ -854,7 +853,9 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
local dXOffset = 0
|
||||
|
||||
-- se i due pezzi hanno angoli di accoppiamento discordi allora uno sta sotto e uno sta sopra
|
||||
local bSameSide = dPairAng * dPairAngPrev > 0
|
||||
|
||||
local bSameSide = false
|
||||
if tbInfo.nPrevId~= GDB_ID.NULL then bSameSide = dPairAng * dPairAngPrev > 0 end
|
||||
if bSameSide then
|
||||
local dOffset = 0
|
||||
if tbInfo.nJunctionType == 3 then
|
||||
@@ -893,7 +894,9 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
end
|
||||
end
|
||||
-- -- calcolo l'angolo di sformo con il pezzo successivo
|
||||
bSameSide = dPairAng * dPairAngNext > 0
|
||||
|
||||
bSameSide = false
|
||||
if tbInfo.nNextId~= GDB_ID.NULL then bSameSide = dPairAng * dPairAngNext > 0 end
|
||||
if bSameSide then
|
||||
local dOffset = 0
|
||||
if tbInfo.nJunctionType == 3 then
|
||||
@@ -935,23 +938,47 @@ function TOOL.CreateParetina(nEdgeId, tbInfo, dPairAngCorr)
|
||||
tbInfo.dXOffset = dXOffset
|
||||
end
|
||||
|
||||
local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
|
||||
local function ClearPart(nPartId)
|
||||
local tbLayer = TOOL.FindLayers(nPartId)
|
||||
-- svuoto i layer con gli elementi principali
|
||||
EgtEmptyGroup(tbLayer["OutLoop"])
|
||||
EgtEmptyGroup(tbLayer["Region"])
|
||||
EgtEmptyGroup(tbLayer["Ref"])
|
||||
EgtEmptyGroup(tbLayer["Labels"])
|
||||
-- rimetto il frame del part nell'origine
|
||||
EgtChangeGroupFrame(nPartId, GLOB_FRM())
|
||||
-- resetto il gruppo di accoppiati
|
||||
ASS.bActiveHistory = false
|
||||
ASS.nPartId = nPartId
|
||||
ASS.Unpair()
|
||||
ASS.bActiveHistory = true
|
||||
-- cancello il solido
|
||||
local PartSolid = EgtGetInfo(TOOL.tbInfo.nId, "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])
|
||||
EgtErase(nRef)
|
||||
end
|
||||
|
||||
local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nNext)
|
||||
local Pz_Bottom = GDB_ID.NULL
|
||||
-- devo verificare se la paretina esiste già allora devo distruggerla e ricrearla, sennò la creo da zero
|
||||
-- N.B.: nEdge è riferito all'edge del parent a cui questo part andrà ad accoppiarsi
|
||||
-- mentre i è l'indice dell'edge del loop dei lati A3 dei parent da cui sto creando il fondo
|
||||
local nChildPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(tbInfo.nParent, "A"..tbInfo.nEdge))
|
||||
if not nChildPart then
|
||||
Pz_Bottom = TOOL.CreatePartLayer('BottomA'..EgtNumToString(i))
|
||||
tbInfo.sName = EgtGetName(Pz_Bottom)
|
||||
EgtSetInfo(tbInfo.nParent, "A"..tbInfo.nEdge, tbInfo.sName)
|
||||
tbInfo.nPrevId = nPrev
|
||||
if i < #tbIdEdges then
|
||||
tbInfo.nNextId = GDB_ID.NULL
|
||||
else
|
||||
tbInfo.nNextId = nFirst
|
||||
end
|
||||
tbInfo.nPrevId = nPrev or GDB_ID.NULL
|
||||
tbInfo.nNextId = i == #tbIdEdges and nNext or GDB_ID.NULL
|
||||
|
||||
-- setto le info per la creazione del pezzo di fondo
|
||||
if i == 1 then nFirst = Pz_Bottom end
|
||||
tbInfo.nId = Pz_Bottom
|
||||
tbInfo.nEdgeId = tbIdEdges[i]
|
||||
tbInfo.sDestRefOff = '0,0,-x'
|
||||
@@ -967,15 +994,17 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
|
||||
TOOL.tbInfo.nId = nChildPart
|
||||
TOOL.tbInfo.sName = EgtGetName(TOOL.tbInfo.nId)
|
||||
-- recupero l'id di eventuali vicini
|
||||
TOOL.tbInfo.nPrevId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(TOOL.tbInfo.nId, "Prev")) or GDB_ID.NULL
|
||||
TOOL.tbInfo.nNextId = EgtGetFirstNameInGroup(GDB_ID.ROOT, EgtGetInfo(TOOL.tbInfo.nId, "Next")) or GDB_ID.NULL
|
||||
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)
|
||||
end
|
||||
-- creo il fondo come paretina
|
||||
local tbLayerBottom = TOOL.FindLayers(tbInfo.nId)
|
||||
tbInfo.nLayLoop = tbLayerBottom['OutLoop']
|
||||
-- da qui mi serve che tbInfo.nEdge indichi quale lato del loop ausiliario sta generando il part corrente(e non sia più riferito al lato del parent)
|
||||
-- nella funzione CreateParetina mi serve che tbInfo.nEdge indichi quale lato del loop ausiliario sta generando il part corrente(e non sia riferito al lato del parent)
|
||||
tbInfo.nEdge = i
|
||||
TOOL.CreateParetina( tbInfo.nEdgeId, tbInfo, 90)
|
||||
-- ripristino il valore di nEdge riferito al Parent
|
||||
tbInfo.nEdge = 3
|
||||
local dLenCorr = 0
|
||||
local dThParent = EgtGetInfo(tbInfo.nParent, "Th", "d")
|
||||
if not tbInfo.bInsideLoop then
|
||||
@@ -1025,10 +1054,6 @@ local function CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
|
||||
ASS.PairSingle()
|
||||
end
|
||||
|
||||
-- debug
|
||||
TOOL.SaveMePlease()
|
||||
-- debug
|
||||
|
||||
return Pz_Bottom
|
||||
end
|
||||
|
||||
@@ -1038,7 +1063,7 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
|
||||
-- riordino gli edge in modo che il primo lato sia il lato lungo del rettangolo
|
||||
local dLen1 = EgtCurveLength(tbIdEdges[1])
|
||||
local dLen2 = EgtCurveLength(tbIdEdges[2])
|
||||
if dLen1 < dLen2 + 0.001 then
|
||||
if dLen1 < dLen2 + GEO.EPS_SMALL then
|
||||
-- sposto il primo elemento in fondo alla tabella
|
||||
table.insert(tbIdEdges, tbIdEdges[1])
|
||||
table.remove(tbIdEdges, 1)
|
||||
@@ -1061,7 +1086,7 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
|
||||
for i = 1, #tbIdEdges do
|
||||
local ptStart = EgtUP(nLoop, i - 1, GDB_ID.ROOT)
|
||||
for j = 1, #tbIdEdges do
|
||||
if dist(ptStart, EgtSP(tbIdEdges[j], GDB_ID.ROOT)) < 0.001 then
|
||||
if dist(ptStart, EgtSP(tbIdEdges[j], GDB_ID.ROOT)) < GEO.EPS_SMALL then
|
||||
table.insert(tbIdEdgesOrd, tbIdEdges[j])
|
||||
break
|
||||
end
|
||||
@@ -1082,8 +1107,6 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
|
||||
local nFirst = GDB_ID.NULL
|
||||
local tbInfo = TOOL.tbInfo
|
||||
|
||||
|
||||
|
||||
-- da intefaccia devo settare:-----------------------------------------------
|
||||
-- - TOOL.tbIdEdges
|
||||
-- - dOffset
|
||||
@@ -1091,57 +1114,37 @@ function TOOL.CreateSplitBottom( tbIdEdges, dOffset)
|
||||
-- - dDiamBore
|
||||
-- - dTh
|
||||
for i = 1, #tbIdEdges do
|
||||
tbInfo.nPrevId = nPrev
|
||||
tbInfo.dTh = TOOL.dTh
|
||||
tbInfo.nParent = tbParent[i]
|
||||
local dThParent = EgtGetInfo(tbInfo.nParent, "Th", "d") or 0
|
||||
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
|
||||
nPrev = CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
|
||||
local nCurr = CreateSplitBottomPart(tbInfo, i, tbIdEdges, nPrev, nFirst)
|
||||
if i == 1 then nFirst = nCurr end
|
||||
if i == #tbIdEdges then tbInfo.nNextId = nFirst end
|
||||
|
||||
-- modifico le paretine vicine se serve
|
||||
local nNextId = TOOL.tbInfo.nNextId
|
||||
local Prev_i = i == 1 and #tbIdEdges or (i - 1)
|
||||
local Next_i = i == #tbIdEdges and 1 or (i + 1)
|
||||
if TOOL.tbInfo.nPrevId and TOOL.tbInfo.nPrevId ~= GDB_ID.NULL then
|
||||
FillInfoTableFromPart(TOOL.tbInfo.nPrevId)
|
||||
TOOL.CreateSplitBottomPart(tbInfo, Prev_i, tbIdEdges, nil, nil, nil) -- da modificare gli input per il prev
|
||||
|
||||
if tbInfo.nPrevId and tbInfo.nPrevId ~= GDB_ID.NULL then
|
||||
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.CreateSplitBottomPart(tbInfo, Next_i, tbIdEdges, nil, nil, nil) -- da modificare gli input per il next\
|
||||
CreateSplitBottomPart(tbInfo, Next_i, tbIdEdges, nCurr, nil) -- da modificare gli input per il next
|
||||
end
|
||||
|
||||
-- pulisco la tabella con i dati
|
||||
tbInfo = {}
|
||||
for j, v in ipairs(tbInfo) do tbInfo[j] = nil end
|
||||
nPrev = nCurr
|
||||
end
|
||||
|
||||
EgtErase(nAuxPart)
|
||||
|
||||
TOOL.SaveMePlease()
|
||||
|
||||
-- cancello layer ed entità che non servono più...
|
||||
|
||||
end
|
||||
|
||||
local function ClearPart(nPartId)
|
||||
local tbLayer = TOOL.FindLayers(nPartId)
|
||||
-- svuoto i layer con gli elementi principali
|
||||
EgtEmptyGroup(tbLayer["OutLoop"])
|
||||
EgtEmptyGroup(tbLayer["Region"])
|
||||
EgtEmptyGroup(tbLayer["Ref"])
|
||||
EgtEmptyGroup(tbLayer["Labels"])
|
||||
-- rimetto il frame del part nell'origine
|
||||
EgtChangeGroupFrame(nPartId, GLOB_FRM())
|
||||
-- resetto il gruppo di accoppiati
|
||||
ASS.bActiveHistory = false
|
||||
ASS.nPartId = nPartId
|
||||
ASS.Unpair()
|
||||
ASS.bActiveHistory = true
|
||||
-- cancello il solido
|
||||
local PartSolid = EgtGetInfo(TOOL.tbInfo.nId, "Child")
|
||||
EgtErase(PartSolid)
|
||||
-- resetto l'id del part del solido
|
||||
EgtSetInfo(nPartId, "Child", "")
|
||||
end
|
||||
|
||||
local function CountInLoops(nEdgeId)
|
||||
@@ -1247,7 +1250,7 @@ function TOOL.CreateParetinaFull(bPrev, bNext, bRecurs)
|
||||
for _, sChildName in pairs(tbChildName) do
|
||||
nChildPart = EgtGetFirstNameInGroup(GDB_ID.ROOT, sChildName)
|
||||
if nChildPart then dPairAng = EgtGetInfo(nChildPart, "PairAng", "d") or 0 end
|
||||
if math.abs(dPairAng - TOOL.tbInfo.dPairAng) < 0.001 then
|
||||
if math.abs(dPairAng - TOOL.tbInfo.dPairAng) < GEO.EPS_SMALL then
|
||||
bFound = true
|
||||
break
|
||||
end
|
||||
@@ -1258,7 +1261,7 @@ function TOOL.CreateParetinaFull(bPrev, bNext, bRecurs)
|
||||
dPairAng = 0
|
||||
end
|
||||
|
||||
if not nChildPart or math.abs(dPairAng - TOOL.tbInfo.dPairAng) > 0.001 then
|
||||
if not nChildPart or math.abs(dPairAng - TOOL.tbInfo.dPairAng) > GEO.EPS_SMALL then
|
||||
-- se il part non esiste, lo creo
|
||||
local sPrefix = "Part"
|
||||
local sPartname = sPrefix..sEdgeName
|
||||
@@ -1291,9 +1294,6 @@ function TOOL.CreateParetinaFull(bPrev, bNext, bRecurs)
|
||||
TOOL.CreateParetina()
|
||||
TOOL.CreateAdjustedPart()
|
||||
TOOL.CreatePart()
|
||||
-- setto i sideAng
|
||||
if TOOL.tbInfo.dSideAngL then TOOL.SetSideAng(tbLayers['OutLoop'], 'A2', TOOL.tbInfo.dSideAngR) end
|
||||
if TOOL.tbInfo.dSideAngR then TOOL.SetSideAng(tbLayers['OutLoop'], 'A4', TOOL.tbInfo.dSideAngL) end
|
||||
-- creo i riferimenti e salvo i parametri del part
|
||||
local sNamePartDest = EgtGetName(TOOL.tbInfo.nParent)
|
||||
local sEdgeDest = EgtGetName(TOOL.tbInfo.nEdgeId)
|
||||
|
||||
Reference in New Issue
Block a user