- tutti i campi Id sostituiti con id (minuscolo)
- in FaceData aggiunta scrittura Edges (GetFaceInfo) e MainEdges (BottomFace e LongFaces)
This commit is contained in:
+149
-75
@@ -18,7 +18,7 @@ function FaceData.GetAdjacencyMatrix( Proc)
|
||||
for i = 1, Proc.nFct do
|
||||
vAdj[i] = {}
|
||||
for j = i + 1, Proc.nFct do
|
||||
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT)
|
||||
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.id, i - 1, j - 1, GDB_ID.ROOT)
|
||||
if not vAdj[i][j] then
|
||||
vAdj[i][j] = 0
|
||||
end
|
||||
@@ -60,10 +60,10 @@ local function GetNotAdjacentFaces( Proc, idFace)
|
||||
local NotAdjacentFaces = {}
|
||||
|
||||
for i = 1, Proc.nFct do
|
||||
if Proc.Faces[i].Id ~= idFace then
|
||||
if Proc.Faces[i].id ~= idFace then
|
||||
local bIsAdjacent = false
|
||||
for j = 1, #Proc.Faces[idFace + 1].Adjacencies do
|
||||
if Proc.Faces[i].Id == Proc.Faces[idFace + 1].Adjacencies[j] then
|
||||
if Proc.Faces[i].id == Proc.Faces[idFace + 1].Adjacencies[j] then
|
||||
bIsAdjacent = true
|
||||
end
|
||||
end
|
||||
@@ -76,20 +76,6 @@ local function GetNotAdjacentFaces( Proc, idFace)
|
||||
return NotAdjacentFaces
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetFacesContactLength( Proc, idFace1, idFace2)
|
||||
local _, ptP1, ptP2 = EgtSurfTmFacetsContact( Proc.Id, idFace1, idFace2, GDB_ID.ROOT)
|
||||
|
||||
local dLength = 0
|
||||
if ptP1 and ptP2 then
|
||||
dLength = dist( ptP1, ptP2)
|
||||
else
|
||||
-- TODO se non trova lunghezza serve dare messaggio di errore?
|
||||
end
|
||||
|
||||
return dLength
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce una tabella che correla numero di adiacenze e id delle facce con quello stesso numero di adiacenze
|
||||
function FaceData.GetFacesByAdjacencyNumber( Proc)
|
||||
@@ -124,14 +110,14 @@ function FaceData.GetFacesInfo( Proc, Part)
|
||||
end
|
||||
|
||||
-- reset eventuali visualizzazioni facce a due colori
|
||||
EgtSurfTmResetTwoColors( Proc.Id)
|
||||
EgtSurfTmResetTwoColors( Proc.id)
|
||||
|
||||
for i = 1, Proc.nFct do
|
||||
Faces[i] = {}
|
||||
Faces[i].Id = i - 1
|
||||
Faces[i].ptCenter, Faces[i].vtN = EgtSurfTmFacetCenter( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
Faces[i].id = i - 1
|
||||
Faces[i].ptCenter, Faces[i].vtN = EgtSurfTmFacetCenter( Proc.id, i - 1, GDB_ID.ROOT)
|
||||
if Proc.nFct < 6 then
|
||||
local frHV, dFaceWidth, dFaceHeight = BeamLib.GetFaceHvRefDim( Proc.Id, i - 1, Part)
|
||||
local frHV, dFaceWidth, dFaceHeight = BeamLib.GetFaceHvRefDim( Proc.id, i - 1, Part)
|
||||
-- frame OCS faccia
|
||||
Faces[i].vtFrameHV = frHV
|
||||
-- larghezza OCS faccia
|
||||
@@ -139,16 +125,17 @@ function FaceData.GetFacesInfo( Proc, Part)
|
||||
-- altezza OCS faccia
|
||||
Faces[i].dHeight = dFaceHeight
|
||||
-- elevazione calcolata rispetto al box della parte
|
||||
Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.Id, i - 1, b3Solid, true, GDB_ID.ROOT)
|
||||
Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.id, i - 1, b3Solid, true, GDB_ID.ROOT)
|
||||
-- TODO qui sarebbe meglio l'area vera e non quella del rettangolo minimo
|
||||
local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Proc.id, i - 1, GDB_ID.ROOT)
|
||||
Faces[i].dArea = dShortEdgeDimension * dLongEdgeDimension
|
||||
|
||||
-- TODO da scrivere in tabella. Cosa fare se nFaceType > 0?
|
||||
local nFaceType, vEdges = EgtSurfTmGetFacetOutlineInfo( Proc.Id, i - 1, GDB_ID.ROOT)
|
||||
local nFaceType, vEdges = EgtSurfTmGetFacetOutlineInfo( Proc.id, i - 1, GDB_ID.ROOT)
|
||||
Faces[i].IsOkForMachining = nFaceType < 1
|
||||
Faces[i].Edges = vEdges
|
||||
|
||||
-- TODO valutare se fare un output unico alla fine o gestire log in altro modo
|
||||
EgtOutLog( 'Facet ' .. Faces[i].Id .. ' of ' .. Proc.nFct - 1)
|
||||
EgtOutLog( 'Facet ' .. Faces[i].id .. ' of ' .. Proc.nFct - 1)
|
||||
EgtOutLog( ' vtN: ' .. tostring( Faces[i].vtN))
|
||||
|
||||
-- adiacenze della faccia
|
||||
@@ -188,7 +175,7 @@ local function GetTunnelFaces( Proc)
|
||||
|
||||
-- centro del tunnel
|
||||
local frTunnel = Frame3d( Proc.Faces[1].ptCenter, vtTunnelDirection)
|
||||
local b3Tunnel = EgtGetBBoxRef( Proc.Id, GDB_BB.STANDARD, frTunnel)
|
||||
local b3Tunnel = EgtGetBBoxRef( Proc.id, GDB_BB.STANDARD, frTunnel)
|
||||
local ptTunnelCenter = b3Tunnel:getCenter()
|
||||
ptTunnelCenter:toGlob( frTunnel)
|
||||
|
||||
@@ -202,10 +189,10 @@ local function GetTunnelFaces( Proc)
|
||||
|
||||
-- faccia centrale, si crea larga come la parte e poi si trimma
|
||||
TunnelAddedFaces.MiddleFaceTm = {}
|
||||
TunnelAddedFaces.MiddleFaceTm.Id = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, b3Part, GDB_ID.ROOT)
|
||||
TunnelAddedFaces.MiddleFaceTm.id = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, b3Part, GDB_ID.ROOT)
|
||||
-- TODO se non si riesce a costruire la faccia bisogna dare errore o semplicemente non ritornarla??
|
||||
for i = 1, Proc.nFct do
|
||||
EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.Id, Proc.Faces[i].ptCenter, -Proc.Faces[i].vtN, false, GDB_ID.ROOT)
|
||||
EgtCutSurfTmPlane( TunnelAddedFaces.MiddleFaceTm.id, Proc.Faces[i].ptCenter, -Proc.Faces[i].vtN, false, GDB_ID.ROOT)
|
||||
end
|
||||
TunnelAddedFaces.MiddleFaceTm.Type = 'Tunnel'
|
||||
|
||||
@@ -229,17 +216,68 @@ local function GetBottomFace( Proc)
|
||||
if #BottomFaces > 1 then
|
||||
local dMinElevation = GEO.INFINITO
|
||||
for i = 1, #BottomFaces do
|
||||
if Proc.Faces[BottomFaces[i].Id + 1].dElevation < dMinElevation then
|
||||
dMinElevation = Proc.Faces[BottomFaces[i].Id + 1].dElevation
|
||||
BottomFace = Proc.Faces[BottomFaces[i].Id + 1]
|
||||
if Proc.Faces[BottomFaces[i].id + 1].dElevation < dMinElevation then
|
||||
dMinElevation = Proc.Faces[BottomFaces[i].id + 1].dElevation
|
||||
BottomFace = Proc.Faces[BottomFaces[i].id + 1]
|
||||
end
|
||||
end
|
||||
else
|
||||
BottomFace = BottomFaces[1]
|
||||
BottomFace.Type = 'Bottom'
|
||||
end
|
||||
end
|
||||
|
||||
if not BottomFace.IsOkForMachining then
|
||||
return nil
|
||||
end
|
||||
|
||||
BottomFace.Type = 'Bottom'
|
||||
BottomFace.MainEdges = {}
|
||||
BottomFace.MainEdges.LongEdges = {}
|
||||
BottomFace.MainEdges.SideEdges = {}
|
||||
|
||||
local EdgesSortedByGreatestLength = {}
|
||||
for i = 1, #BottomFace.Edges do
|
||||
EdgesSortedByGreatestLength[i] = {}
|
||||
EdgesSortedByGreatestLength[i].nIndex = i
|
||||
EdgesSortedByGreatestLength[i].dLength = BottomFace.Edges[i].Len
|
||||
end
|
||||
table.sort( EdgesSortedByGreatestLength, function (a, b) return a.dLength > b.dLength end)
|
||||
local nFirstLongEdgeIndex = EdgesSortedByGreatestLength[1].nIndex
|
||||
|
||||
for i = 1, #BottomFace.Edges do
|
||||
local nPreviousEdgeIndex = i - 1
|
||||
if i == 1 then
|
||||
nPreviousEdgeIndex = #BottomFace.Edges
|
||||
end
|
||||
local nNextEdgeIndex = i + 1
|
||||
if i == #BottomFace.Edges then
|
||||
nNextEdgeIndex = 1
|
||||
end
|
||||
|
||||
local CurrentEdge = {}
|
||||
CurrentEdge.idAdjacentFace = BottomFace.Edges[i].Adj
|
||||
CurrentEdge.vtToolDirection = Vector3d( BottomFace.Edges[i].Norm)
|
||||
CurrentEdge.dLength = BottomFace.Edges[i].Len
|
||||
CurrentEdge.dElevation = BottomFace.Edges[i].Elev
|
||||
CurrentEdge.bIsOpen = BottomFace.Edges[i].Open
|
||||
CurrentEdge.bIsStartOpen = BottomFace.Edges[nPreviousEdgeIndex].Open
|
||||
CurrentEdge.bIsEndOpen = BottomFace.Edges[nNextEdgeIndex].Open
|
||||
|
||||
if i == nFirstLongEdgeIndex then
|
||||
BottomFace.MainEdges.LongEdges[1] = CurrentEdge
|
||||
BottomFace.MainEdges.LongEdges[1].Type = 'Long'
|
||||
elseif nNextEdgeIndex == nFirstLongEdgeIndex then
|
||||
BottomFace.MainEdges.SideEdges[1] = CurrentEdge
|
||||
BottomFace.MainEdges.SideEdges[1].Type = 'Side'
|
||||
elseif nPreviousEdgeIndex == nFirstLongEdgeIndex then
|
||||
BottomFace.MainEdges.SideEdges[2] = CurrentEdge
|
||||
BottomFace.MainEdges.SideEdges[2].Type = 'Side'
|
||||
else
|
||||
BottomFace.MainEdges.LongEdges[2] = CurrentEdge
|
||||
BottomFace.MainEdges.LongEdges[2].Type = 'Long'
|
||||
end
|
||||
end
|
||||
|
||||
return BottomFace
|
||||
end
|
||||
|
||||
@@ -251,46 +289,82 @@ local function GetLongFaces( Proc, MainFaces)
|
||||
error( 'GetLongFaces : Topology not implemented')
|
||||
end
|
||||
|
||||
local idBottomFace = GDB_ID.NULL
|
||||
local idTunnelMiddleFace = GDB_ID.NULL
|
||||
if Proc.Topology.sFamily == 'Tunnel' then
|
||||
if MainFaces.TunnelAddedFaces then
|
||||
idTunnelMiddleFace = MainFaces.TunnelAddedFaces.MiddleFaceTm.Id
|
||||
else
|
||||
local TunnelAddedFaces = GetTunnelFaces( Proc)
|
||||
idTunnelMiddleFace = TunnelAddedFaces.MiddleFaceTm.Id or idTunnelMiddleFace
|
||||
local BottomFace = MainFaces.BottomFace or GetBottomFace( Proc)
|
||||
|
||||
local nFirstLongFaceId = GDB_ID.NULL
|
||||
local nSecondLongFaceId = GDB_ID.NULL
|
||||
if not BottomFace then
|
||||
local FacesSortedByGreatestArea = {}
|
||||
for i = 1, Proc.nFct do
|
||||
FacesSortedByGreatestArea[i] = {}
|
||||
FacesSortedByGreatestArea[i].id = Proc.Faces[i].id
|
||||
FacesSortedByGreatestArea[i].dArea = Proc.Faces[i].dArea
|
||||
end
|
||||
table.sort( FacesSortedByGreatestArea, function (a, b) return a.dArea > b.dArea end)
|
||||
nFirstLongFaceId = FacesSortedByGreatestArea[1].id
|
||||
local FacesNotAdjacent = GetNotAdjacentFaces( Proc, nFirstLongFaceId)
|
||||
nSecondLongFaceId = FacesNotAdjacent[1].id
|
||||
else
|
||||
if MainFaces.BottomFace then
|
||||
idBottomFace = MainFaces.BottomFace.Id
|
||||
else
|
||||
local BottomFace = GetBottomFace( Proc)
|
||||
idBottomFace = BottomFace.Id or idBottomFace
|
||||
if not BottomFace.MainEdges.LongEdges[1].bIsOpen then
|
||||
nFirstLongFaceId = BottomFace.MainEdges.LongEdges[1].idAdjacentFace
|
||||
end
|
||||
if not BottomFace.MainEdges.LongEdges[2].bIsOpen then
|
||||
nSecondLongFaceId = BottomFace.MainEdges.LongEdges[2].idAdjacentFace
|
||||
end
|
||||
end
|
||||
if nFirstLongFaceId > -1 then
|
||||
LongFaces[1] = Proc.Faces[nFirstLongFaceId + 1]
|
||||
end
|
||||
if nSecondLongFaceId > -1 then
|
||||
LongFaces[2] = Proc.Faces[nSecondLongFaceId + 1]
|
||||
end
|
||||
|
||||
local FacesToAnalyze = {}
|
||||
for i = 1, Proc.nFct do
|
||||
if Proc.Faces[i].Id ~= idBottomFace then
|
||||
table.insert( FacesToAnalyze, Proc.Faces[i])
|
||||
FacesToAnalyze[#FacesToAnalyze].LengthOnMainFace = GetFacesContactLength( Proc, idBottomFace, Proc.Faces[i].Id)
|
||||
end
|
||||
end
|
||||
if Proc.Topology.sFamily == 'Tunnel' then
|
||||
table.sort( FacesToAnalyze, function( a, b) return a.dArea > b.dArea end)
|
||||
else
|
||||
table.sort( FacesToAnalyze, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end)
|
||||
end
|
||||
for i = 1, #LongFaces do
|
||||
LongFaces[i].Type = 'Long'
|
||||
LongFaces[i].MainEdges = {}
|
||||
LongFaces[i].MainEdges.SideEdges = {}
|
||||
LongFaces[i].MainEdges.OppositeEdges = {}
|
||||
|
||||
-- la prima faccia lunga è sempre la prima della lista
|
||||
LongFaces[1] = FacesToAnalyze[1]
|
||||
LongFaces[1].Type = 'Long'
|
||||
-- si cerca l'eventuale seconda faccia lunga, ossia quella non adiacente alla prima
|
||||
if Proc.nFct > 3 then
|
||||
local NotAdjacentFaces = GetNotAdjacentFaces(Proc, LongFaces[1].Id)
|
||||
if #NotAdjacentFaces > 0 then
|
||||
LongFaces[2] = NotAdjacentFaces[1]
|
||||
LongFaces[2].Type = 'Long'
|
||||
for j = 1, #LongFaces[i].Edges do
|
||||
local nPreviousEdgeIndex = j - 1
|
||||
if j == 1 then
|
||||
nPreviousEdgeIndex = #LongFaces[1].Edges
|
||||
end
|
||||
local nNextEdgeIndex = j + 1
|
||||
if j == #LongFaces[i].Edges then
|
||||
nNextEdgeIndex = 1
|
||||
end
|
||||
|
||||
local CurrentEdge = {}
|
||||
CurrentEdge.idAdjacentFace = LongFaces[i].Edges[j].Adj
|
||||
CurrentEdge.vtToolDirection = Vector3d( LongFaces[i].Edges[j].Norm)
|
||||
CurrentEdge.dLength = LongFaces[i].Edges[j].Len
|
||||
CurrentEdge.dElevation = LongFaces[i].Edges[j].Elev
|
||||
CurrentEdge.bIsOpen = LongFaces[i].Edges[j].Open
|
||||
CurrentEdge.bIsStartOpen = LongFaces[i].Edges[nPreviousEdgeIndex].Open
|
||||
CurrentEdge.bIsEndOpen = LongFaces[i].Edges[nNextEdgeIndex].Open
|
||||
|
||||
if Proc.Topology.sFamily == 'Tunnel' then
|
||||
if CurrentEdge.idAdjacentFace > -1 then
|
||||
table.insert( LongFaces[i].MainEdges.SideEdges, CurrentEdge)
|
||||
else
|
||||
table.insert( LongFaces[i].MainEdges.OppositeEdges, CurrentEdge)
|
||||
end
|
||||
else
|
||||
if CurrentEdge.idAdjacentFace == BottomFace.id then
|
||||
LongFaces[i].MainEdges.BottomEdge = CurrentEdge
|
||||
LongFaces[i].MainEdges.BottomEdge.Type = 'Bottom'
|
||||
elseif LongFaces[i].Edges[nNextEdgeIndex].Adj == BottomFace.id then
|
||||
LongFaces[i].MainEdges.SideEdges[1] = CurrentEdge
|
||||
LongFaces[i].MainEdges.SideEdges[1].Type = 'Side'
|
||||
elseif LongFaces[i].Edges[nPreviousEdgeIndex].Adj == BottomFace.id then
|
||||
LongFaces[i].MainEdges.SideEdges[2] = CurrentEdge
|
||||
LongFaces[i].MainEdges.SideEdges[2].Type = 'Side'
|
||||
else
|
||||
table.insert( LongFaces[i].MainEdges.OppositeEdges, CurrentEdge)
|
||||
LongFaces[i].MainEdges.OppositeEdges[#LongFaces[i].MainEdges.OppositeEdges].Type = 'Opposite'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -308,10 +382,10 @@ local function GetSideFaces( Proc, MainFaces)
|
||||
local idBottomFace = GDB_ID.NULL
|
||||
if Proc.Topology.sFamily ~= 'Tunnel' then
|
||||
if MainFaces.BottomFace then
|
||||
idBottomFace = MainFaces.BottomFace.Id
|
||||
idBottomFace = MainFaces.BottomFace.id
|
||||
else
|
||||
local BottomFace = GetBottomFace( Proc)
|
||||
idBottomFace = BottomFace.Id or idBottomFace
|
||||
idBottomFace = BottomFace.id or idBottomFace
|
||||
end
|
||||
end
|
||||
|
||||
@@ -327,7 +401,7 @@ local function GetSideFaces( Proc, MainFaces)
|
||||
if not idBottomFace or i ~= ( idBottomFace + 1) then
|
||||
local bIsSideFace = true
|
||||
for j = 1, #LongFaces do
|
||||
if Proc.Faces[i].Id == LongFaces[j].Id then
|
||||
if Proc.Faces[i].id == LongFaces[j].id then
|
||||
bIsSideFace = false
|
||||
break
|
||||
end
|
||||
@@ -363,21 +437,21 @@ function FaceData.GetMainFaces( Proc)
|
||||
if EgtGetDebugLevel() >= 3 then
|
||||
if MainFaces.BottomFace then
|
||||
-- colore differente per la faccia di fondo
|
||||
EgtSurfTmSetFaceColor( Proc.Id, MainFaces.BottomFace.Id, 1)
|
||||
EgtOutLog( 'Bottom Face : ' .. MainFaces.BottomFace.Id)
|
||||
EgtSurfTmSetFaceColor( Proc.id, MainFaces.BottomFace.id, 1)
|
||||
EgtOutLog( 'Bottom Face : ' .. MainFaces.BottomFace.id)
|
||||
end
|
||||
if MainFaces.LongFaces then
|
||||
for i = 1, #MainFaces.LongFaces do
|
||||
EgtOutLog( 'Long Face : ' .. MainFaces.LongFaces[i].Id)
|
||||
EgtOutLog( 'Long Face : ' .. MainFaces.LongFaces[i].id)
|
||||
end
|
||||
end
|
||||
if MainFaces.SideFaces then
|
||||
for i = 1, #MainFaces.SideFaces do
|
||||
EgtOutLog( 'Side Face : ' .. MainFaces.SideFaces[i].Id)
|
||||
EgtOutLog( 'Side Face : ' .. MainFaces.SideFaces[i].id)
|
||||
end
|
||||
end
|
||||
if MainFaces.TunnelAddedFaces then
|
||||
EgtOutLog( 'Middle Face (Trimesh): ' .. MainFaces.TunnelAddedFaces.MiddleFaceTm.Id)
|
||||
EgtOutLog( 'Middle Face (Trimesh): ' .. MainFaces.TunnelAddedFaces.MiddleFaceTm.id)
|
||||
end
|
||||
end
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user