aggiunta gestione dei loop interni con archi con sideAng ( manca gestione Heel in questi casi)

This commit is contained in:
Daniele Bariletti
2024-10-02 10:19:11 +02:00
parent 12890da212
commit fb92ae324c
+157 -122
View File
@@ -10,13 +10,18 @@ require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\debug_buche_sottili.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\debug_buche_sottili.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\buca_squadrata.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\buca_squadrata45.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\buca_squadrata-45.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\sideAng_archi_Interni_-45.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\sideAng_archi_Interni_45.nge")
--EgtOpenFile( "C:\\EgtData\\OmagOFFICE\\Temp\\buca_limitata.nge")
-- Dati raccolti direttamente dal programma
local CMP = {}
--input
CMP.THICK = 20
CMP.THICK = 40
CMP.CurrId = -1
-- output
CMP.CurrPartSolid = -1
@@ -105,7 +110,7 @@ local function ResetAllTabAndVar()
tbId_Pocket = {}
-- tabella contenente le curve composte del layer FiloTop: IdI →
tbId_FiloTop = {}
-- Id del solido generato
-- Id del solido generato
IdEnt_Part = -1
-- Id del solido da sottrarre
IdEnt_SubPart = -1
@@ -496,6 +501,7 @@ end
-- **Side Ang**
----------------------------------------------------------------------------
local function SideAngSolid( tbLoop, bInLoop)
local tbIdR = {}
local IdS
local Ang = 0
@@ -504,20 +510,21 @@ local function SideAngSolid( tbLoop, bInLoop)
m_bArc = false
local tbArc = {}
local tbLimited = {}
for i=1, #tbLoop, 1 do
IdS = tbLoop[i]
-- recupero i dati SideAng per ogni lato
Ang, Hill = GetAngHill( IdS)
NAng = GetnNextAng( IdS)
if math.abs(NAng) <= 2 then NAng = 0 end
-- PAng = GetnPrevAng( IdS)
-- if math.abs(PAng) <= 2 then PAng = 0 end
-- verifico che il lato presenti un angolo inclinato
--if ( math.abs( Ang) > 0.1 or bInLoop) and ( EgtGetType( IdS) ~= GDB_TY.CRV_ARC and EgtGetType( IdS) ~= GDB_TY.CRV_COMPO) then
if EgtGetType( IdS) == GDB_TY.CRV_ARC then
m_bArc = true
table.insert(tbArc, true)
local ptStart = EgtSP(IdS, GDB_ID.ROOT)
local vtStart = EgtSV( IdS, GDB_ID.ROOT)
local vtEnd = EgtEV( IdS, GDB_ID.ROOT)
if Ang == 0 then
local vtExtr = Z_AX() * RTh
if bAlwaysOnTop then
@@ -527,14 +534,59 @@ local function SideAngSolid( tbLoop, bInLoop)
if bAlwaysOnTop then
EgtInvertSurf( nSurfId)
end
local ptStart = EgtSP(IdS, GDB_ID.ROOT)
local vtStart = EgtSV( IdS, GDB_ID.ROOT)
local vtEnd = EgtEV( IdS, GDB_ID.ROOT)
local tbInfoRot = { nSurfId, ptStart, vtStart, Ang, Hill, NAng, vtEnd}
table.insert(tbIdR,tbInfoRot)
table.insert(tbLimited, false)
else
-- qui resta da gestire il caso con la superficie laterale che è un tronco di cono----
------
-- costruisco la superficie laterale generata dall'arco con una swept lungo l'arco stesso
-- la sezione di cui effetturare lo sweep viene creata trovando il punto di partenza del secondo arco che delimita questa superficie
local dLatMove = RTh * math.tan( math.abs(Ang) * pi / 180)
local vtLatMove = (Z_AX() ^ vtStart)
local vtVertMove = Z_AX() * RTh
if not bInLoop then vtLatMove = vtLatMove * (-1) end
-- devo controllare se il side ang e lo spessore della lastra sono abbastanza da far collassare l'arco in un punto ed eventualmente andare oltre
-- verifico quindi se devo limitare la superficie della sezione di cono
local dRad = EgtArcRadius( IdS)
local bLimited = false
local dArcAng = EgtArcAngCenter( IdS)
local bCheckLimit = (dArcAng > 0 and Ang < 0 ) or ( dArcAng < 0 and Ang > 0)
if bCheckLimit then
if dRad < math.abs(dLatMove) + 0.01 then
vtLatMove = vtLatMove * dRad
vtVertMove = Z_AX() * dRad / math.tan( math.abs(Ang) * pi / 180)
bLimited = true
end
else
vtLatMove = vtLatMove * dLatMove
end
table.insert(tbLimited, bLimited)
if (Ang > 0 and bAlwaysOnTop) or ( Ang < 0 and not bAlwaysOnTop) then
vtLatMove = vtLatMove * ( -1)
end
if bAlwaysOnTop then
vtVertMove = vtVertMove * (-1)
end
local ptSecondArcStart = ptStart + ( vtVertMove + vtLatMove)
local nIdLine = EgtLine(IdL_Temp,ptStart,ptSecondArcStart,GDB_ID.ROOT)
local nPointId = EgtPoint( IdL_Temp, ptSecondArcStart)
local nSurfId = 0
if not bLimited then
nSurfId = EgtSurfTmSwept(IdL_Solid,nIdLine,IdS,Z_AX(),false,0.01,GDB_ID.ROOT)
EgtInvertSurf( nSurfId)
else
local vtAx = Z_AX()
if not bAlwaysOnTop then
vtAx = vtAx * (-1)
end
nSurfId = EgtSurfTmRuled( IdL_Solid, nPointId, IdS)
EgtInvertSurf( nSurfId)
-- nSurfId = EgtSurfTmCone(IdL_Solid,ptSecondArcStart, vtAx, dRad, RTh)
end
EgtErase( nIdLine)
EgtErase( nPointId)
local tbInfoRot = { nSurfId, ptStart, vtStart, Ang, Hill, NAng, vtEnd}
table.insert(tbIdR,tbInfoRot)
end
elseif EgtGetType( IdS) ~= GDB_TY.CRV_COMPO then
table.insert(tbArc, false)
@@ -542,22 +594,15 @@ local function SideAngSolid( tbLoop, bInLoop)
local vtS = EgtSV( IdS, GDB_ID.ROOT)
local vtE = EgtEV( IdS, GDB_ID.ROOT)
local IdRect = EgtCurveGetFatCurve( IdS, IdL_Temp, 100, true)
if bInLoop then
--EgtInvertCurve( IdRect)
end
local IdSurf = EgtSurfTmByRegion( IdL_Solid, IdRect)
EgtErase( IdRect)
local tbInfoRot = { IdSurf, ptS, vtS, Ang, Hill, NAng, vtE}
table.insert( tbIdR, tbInfoRot)
table.insert(tbLimited, false)
end
end
if m_bArc then
--do return end -- debug
local a = 0
end
-- posiziono i piani calcolati in precedenza e creo i piani di Hill
for i=1, #tbIdR, 1 do
local dTempAng = 90
@@ -579,116 +624,106 @@ local function SideAngSolid( tbLoop, bInLoop)
end
end
if m_bArc then
--do return end -- debug
local a = 0
end
if bInLoop then
local b = 0 -- debug
end
-- **NANG** corrego la dimenione dei piani in funzione dell'angolo che descrivono con il pezzo successivo
for i=1, #tbIdR, 1 do
local Ind_Pre = i
local Ind_Curr = i
local Ind_Nex = i + 1
if i == #tbIdR then
Ind_Nex = 1
end
local pt_n, vn_n = EgtSurfTmFacetCenter( tbIdR[Ind_Nex][1], 0)
local pt_p, vn_p = EgtSurfTmFacetCenter( tbIdR[Ind_Pre][1], 0)
local pt_c, vn_c = EgtSurfTmFacetCenter( tbIdR[Ind_Curr][1], 0)
if tbArc[Ind_Nex] then
pt_n = tbIdR[Ind_Nex][2] -- prendo startPoint
vn_n = tbIdR[Ind_Nex][3] -- prendo vtStart
if math.abs( tbIdR[Ind_Pre][6]) > 90 then
if math.abs( tbIdR[Ind_Curr][6]) > 90 then
vn_n = vn_n * (-1)
elseif math.abs( tbIdR[Ind_Pre][6]) > 90 then
vn_n = EgtEV( tbLoop[Ind_Pre], GDB_ID.ROOT) -- prendo l'end del segmento precedente all'arco
elseif math.abs( tbIdR[Ind_Curr][6]) > 90 then
vn_n = EgtEV( tbLoop[Ind_Curr], GDB_ID.ROOT) -- prendo l'end del segmento precedente all'arco
end
end
if tbArc[Ind_Pre] then
pt_p = EgtEP( tbLoop[Ind_Pre], GDB_ID.ROOT) -- prendo endPoint
vn_p = tbIdR[Ind_Pre][7] -- prendo vtEnd
if math.abs( tbIdR[Ind_Pre][6]) < 90 then
vn_p = vn_p * (-1)
elseif math.abs( tbIdR[Ind_Pre][6]) > 90 then
vn_p = tbIdR[Ind_Nex][3] -- prendo lo start del segmento successivo all'arco
if tbArc[Ind_Curr] then
pt_c = EgtEP( tbLoop[Ind_Curr], GDB_ID.ROOT) -- prendo endPoint
vn_c = tbIdR[Ind_Curr][7] -- prendo vtEnd
if math.abs( tbIdR[Ind_Curr][6]) < 90 then
vn_c = vn_c * (-1)
elseif math.abs( tbIdR[Ind_Curr][6]) > 90 then
vn_c = tbIdR[Ind_Nex][3] -- prendo lo start del segmento successivo all'arco
end
end
if (not tbArc[Ind_Nex]) and (not tbArc[Ind_Pre]) then
if ( tbIdR[Ind_Pre][6] < 0) then
if (not tbArc[Ind_Nex]) and (not tbArc[Ind_Curr]) then
if ( tbIdR[Ind_Curr][6] < 0) then
vn_n = vn_n * (-1)
vn_p = vn_p * (-1)
vn_c = vn_c * (-1)
end
end
-- devo tagliare le superfici di taglio con le superfici di taglio
-- gli archi non sono da tagliare
if not tbArc[Ind_Pre] then
EgtCutSurfTmPlane( tbIdR[Ind_Pre][1], pt_n, vn_n, false)
-- gli archi li taglio usando i suoi vettori a inizio e fine curva
if tbArc[Ind_Curr] then
EgtCutSurfTmPlane( tbIdR[Ind_Curr][1], tbIdR[Ind_Curr][2], - tbIdR[Ind_Curr][3], false)
EgtCutSurfTmPlane( tbIdR[Ind_Curr][1], EgtEP(tbLoop[Ind_Curr], GDB_ID.ROOT), tbIdR[Ind_Curr][7], false)
else
EgtCutSurfTmPlane( tbIdR[Ind_Curr][1], pt_n, vn_n, false)
end
if not tbArc[Ind_Nex] then
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], pt_p, vn_p, false)
end
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], pt_c, vn_c, false)
end
-- nel caso in cui la superficie generata dall'arco è limitata devo tagliare tra loro anche le superfici precedente e successiva all'arco--------------------------------------------------
if tbLimited[Ind_Curr] then
local Ind_Pre = Ind_Curr > 1 and (Ind_Curr - 1) or #tbLoop
local pt_p, vn_p = EgtSurfTmFacetCenter( tbIdR[Ind_Pre][1], 0)
pt_n, vn_n = EgtSurfTmFacetCenter( tbIdR[Ind_Nex][1], 0)
-- calcolo l'angolo tra le due facce
local dArcAng = EgtArcAngCenter( tbLoop[Ind_Curr])
local dAngSkip = tbIdR[Ind_Pre][6] + tbIdR[Ind_Nex][6] + dArcAng
if dAngSkip < 0 then
vn_p = vn_p * (-1)
vn_n = vn_n * (-1)
end
EgtCutSurfTmPlane( tbIdR[Ind_Pre][1], pt_n, vn_n, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], pt_p, vn_p, false)
end
--taglio i piani dei talloni con i piani dei talloni ( se non ho un altro tallone allora taglio con la sup di taglio)
local pt_nH, vn_nH
local pt_pH, vn_pH
if tbIdR[Ind_Pre][5] > 0 then
pt_pH, vn_pH = EgtSurfTmFacetCenter( tbIdR[Ind_Pre][9][1], 0)
if ( tbIdR[Ind_Pre][6] < 0) then
vn_pH = vn_pH * (-1)
local pt_cH, vn_cH
if tbIdR[Ind_Curr][5] > 0 then
pt_cH, vn_cH = EgtSurfTmFacetCenter( tbIdR[Ind_Curr][9][1], 0)
if ( tbIdR[Ind_Curr][6] < 0) then
vn_cH = vn_cH * (-1)
end
end
if tbIdR[Ind_Nex][5] > 0 then
pt_nH, vn_nH = EgtSurfTmFacetCenter( tbIdR[Ind_Nex][9][1], 0)
if ( tbIdR[Ind_Pre][6] < 0) then
if ( tbIdR[Ind_Curr][6] < 0) then
vn_nH = vn_nH * (-1)
end
if tbIdR[Ind_Pre][5] > 0 then
EgtCutSurfTmPlane( tbIdR[Ind_Pre][9][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], tbIdR[Ind_Pre][9][2], vn_pH, false)
if tbIdR[Ind_Curr][5] > 0 then
EgtCutSurfTmPlane( tbIdR[Ind_Curr][9][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], tbIdR[Ind_Curr][9][2], vn_cH, false)
-- se l'angolo con il prossimo lato è positivo, entrambi hanno un hill e gli Ang sono discordi, allora devo anche tagliare gli hill con i piani di taglio e viceversa
--if tbIdR[Ind_Pre][6] > 0 and tbIdR[Ind_Pre][4] * tbIdR[Ind_Nex][4] < 0 then
if tbIdR[Ind_Pre][6] > 0 then -- ho tolto la condizione che gli angoli debbano essere discordi!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], pt_p, vn_p, false)
EgtCutSurfTmPlane( tbIdR[Ind_Pre][9][1], pt_n, vn_n, false)
EgtCutSurfTmPlane( tbIdR[Ind_Pre][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], tbIdR[Ind_Pre][9][2], vn_pH, false)
--if tbIdR[Ind_Curr][6] > 0 and tbIdR[Ind_Curr][4] * tbIdR[Ind_Nex][4] < 0 then
if tbIdR[Ind_Curr][6] > 0 then -- ho tolto la condizione che gli angoli debbano essere discordi!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], pt_c, vn_c, false)
EgtCutSurfTmPlane( tbIdR[Ind_Curr][9][1], pt_n, vn_n, false)
EgtCutSurfTmPlane( tbIdR[Ind_Curr][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], tbIdR[Ind_Curr][9][2], vn_cH, false)
end
else
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], pt_p, vn_p, false)
EgtCutSurfTmPlane( tbIdR[Ind_Pre][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][9][1], pt_c, vn_c, false)
EgtCutSurfTmPlane( tbIdR[Ind_Curr][1], tbIdR[Ind_Nex][9][2], vn_nH, false)
end
else
if tbIdR[Ind_Pre][5] > 0 then
EgtCutSurfTmPlane( tbIdR[Ind_Pre][9][1], pt_n, vn_n, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], tbIdR[Ind_Pre][9][2], vn_pH, false)
if tbIdR[Ind_Curr][5] > 0 then
EgtCutSurfTmPlane( tbIdR[Ind_Curr][9][1], pt_n, vn_n, false)
EgtCutSurfTmPlane( tbIdR[Ind_Nex][1], tbIdR[Ind_Curr][9][2], vn_cH, false)
end
end
end
-- -- se ho archi nei loop creo la superficie laterale dei rispettivi cilindri
-- if m_bArc then
-- local vtExtr = Z_AX() * RTh
-- if bAlwaysOnTop then
-- vtExtr = vtExtr * (-1)
-- end
-- for i=1, #tbLoop, 1 do
-- IdS = tbLoop[i]
-- if EgtGetType( IdS) == GDB_TY.CRV_ARC then
-- local nSurfId = EgtSurfTmByExtrusion(IdL_Solid, IdS, vtExtr)
-- local ptStart = EgtSP(IdS, GDB_ID.ROOT)
-- local tbInfoRot = { nSurfId, ptStart, {0,0,0}, 0, 0, 0}
-- table.insert(tbIdR,tbInfoRot)
-- end
-- end
-- end
--do return end -- debug
-- unisco tutte le superfici laterali
local tbIdTrim = {}
for i=1, #tbIdR, 1 do
@@ -849,51 +884,51 @@ local function Draw(bPreview)
-- WIREFRAME
--ExtractBoundaryAndFaces()
ExtractBoundaryAndFaces()
--EgtSetGridFrame({{0,0,0},{1,0,0},{0,1,0},{0,0,1}})
end
--
----per uso nell' |omagOFFICE|
--function CMP.Main()
-- IdFP = CMP.CurrId
-- ClearCurrIdSOLID()
-- if IdFP == -1 then
-- CMP.ERR = 1
-- return
-- end
-- RTh = CMP.THICK
-- if RTh == 0 then
-- return
-- end
-- Draw( true)
-- EgtSetStatus( IdFP, GDB_ST.OFF)
-- EgtSaveFile('c:\\EgtData\\OmagOFFICE\\Temp\\Ribasso_0.nge')
-- EgtDraw()
-- CMP.ERR = 0
--end
--per uso nell' |omagOFFICE|
function CMP.Main()
IdFP = CMP.CurrId
ClearCurrIdSOLID()
if IdFP == -1 then
CMP.ERR = 1
return
end
RTh = CMP.THICK
if RTh == 0 then
return
end
Draw( true)
EgtSetStatus( IdFP, GDB_ST.OFF)
--EgtSaveFile('c:\\EgtData\\OmagOFFICE\\Temp\\Ribasso_0.nge')
EgtDraw()
CMP.ERR = 0
end
--per uso nell' |omagOFFICE|
--per uso nel |CAM5|
ClearCurrIdSOLID()
RTh = 20
IdFP = EgtGetFirstPart()
local sName = ""
--IdFP = 49389
while IdFP ~= nil and sName ~= "SOLID" do
Draw( true)
EgtSetStatus( IdFP, GDB_ST.OFF)
IdFP = EgtGetNextPart(IdFP)
sName = EgtGetName(IdFP)
--break
end
--EgtSaveFile('c:\\EgtData\\OmagOFFICE\\Temp\\buche_sottili_SOLID.nge')
EgtDraw()
----per uso nel |CAM5|
--ClearCurrIdSOLID()
--RTh = CMP.THICK
--IdFP = EgtGetFirstPart()
--local sName = ""
----IdFP = 49389
--while IdFP ~= nil and sName ~= "SOLID" do
-- Draw( true)
-- EgtSetStatus( IdFP, GDB_ST.OFF)
-- IdFP = EgtGetNextPart(IdFP)
-- sName = EgtGetName(IdFP)
-- --break
--end
----EgtSaveFile('c:\\EgtData\\OmagOFFICE\\Temp\\buche_sottili_SOLID.nge')
--EgtDraw()
----CMP.ERR = 0
--per uso nel |CAM5|
-------per uso nel |CAM5|
--_G.CMP_Main = CMP_Main