- BottomFace diventa BottomFaces e comprende tutte le possibili facce di fondo. La [1] è sempre quella a minore elevazione (sono ordinate).
- modifiche a AddNewMachining e di conseguenza alle strategie
This commit is contained in:
+78
-65
@@ -194,8 +194,8 @@ local function GetTunnelFaces( Proc, Part)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function GetBottomFace( Proc)
|
||||
local BottomFace = {}
|
||||
local function GetBottomFaces( Proc)
|
||||
local BottomFaces = {}
|
||||
|
||||
if Proc.Topology.sFamily == 'Tunnel' then
|
||||
return nil
|
||||
@@ -203,78 +203,81 @@ local function GetBottomFace( Proc)
|
||||
error( 'GetBottomFace : Topology not implemented')
|
||||
end
|
||||
|
||||
-- la faccia di fondo ha sempre Fct - 1 adiacenze. Se si trovano più facce di fondo si sceglie quella con minor elevazione
|
||||
-- la faccia di fondo ha sempre Fct - 1 adiacenze
|
||||
local FacesByAdjacencyNumber = FaceData.GetFacesByAdjacencyNumber( Proc)
|
||||
if FacesByAdjacencyNumber then
|
||||
local BottomFaces = FacesByAdjacencyNumber[ Proc.nFct - 1]
|
||||
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]
|
||||
end
|
||||
BottomFaces = FacesByAdjacencyNumber[ Proc.nFct - 1]
|
||||
-- si rimuovono le facce non adatte ad essere lavorate
|
||||
local nBottomFaces = #BottomFaces
|
||||
local nCurrentFace = 1
|
||||
while nCurrentFace <= nBottomFaces do
|
||||
if not BottomFaces[nCurrentFace].bIsOkForMachining then
|
||||
table.remove( BottomFaces, nCurrentFace)
|
||||
nBottomFaces = nBottomFaces - 1
|
||||
end
|
||||
else
|
||||
BottomFace = BottomFaces[1]
|
||||
nCurrentFace = nCurrentFace + 1
|
||||
end
|
||||
-- la BottomFace 1 è sempre quella con minor elevazione
|
||||
table.sort( BottomFaces, function (a, b) return a.dElevation < b.dElevation end)
|
||||
end
|
||||
|
||||
if not BottomFace.bIsOkForMachining then
|
||||
if #BottomFaces == 0 then
|
||||
return nil
|
||||
end
|
||||
|
||||
BottomFace.Type = 'Bottom'
|
||||
BottomFace.MainEdges = {}
|
||||
BottomFace.MainEdges.LongEdges = {}
|
||||
BottomFace.MainEdges.SideEdges = {}
|
||||
|
||||
local ClosedEdgesSortedByGreatestLength = {}
|
||||
for i = 1, #BottomFace.Edges do
|
||||
if not BottomFace.Edges[i].Open then
|
||||
table.insert( ClosedEdgesSortedByGreatestLength, {})
|
||||
ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].nIndex = i
|
||||
ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].dLength = BottomFace.Edges[i].Len
|
||||
for i = 1, #BottomFaces do
|
||||
BottomFaces[i].Type = 'Bottom'
|
||||
BottomFaces[i].MainEdges = {}
|
||||
BottomFaces[i].MainEdges.LongEdges = {}
|
||||
BottomFaces[i].MainEdges.SideEdges = {}
|
||||
|
||||
local ClosedEdgesSortedByGreatestLength = {}
|
||||
for j = 1, #BottomFaces[i].Edges do
|
||||
if not BottomFaces[i].Edges[j].Open then
|
||||
table.insert( ClosedEdgesSortedByGreatestLength, {})
|
||||
ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].nIndex = j
|
||||
ClosedEdgesSortedByGreatestLength[#ClosedEdgesSortedByGreatestLength].dLength = BottomFaces[i].Edges[j].Len
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort( ClosedEdgesSortedByGreatestLength, function (a, b) return a.dLength > b.dLength end)
|
||||
local nFirstLongEdgeIndex = ClosedEdgesSortedByGreatestLength[1].nIndex
|
||||
table.sort( ClosedEdgesSortedByGreatestLength, function (a, b) return a.dLength > b.dLength end)
|
||||
local nFirstLongEdgeIndex = ClosedEdgesSortedByGreatestLength[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
|
||||
for j = 1, #BottomFaces[i].Edges do
|
||||
local nPreviousEdgeIndex = j - 1
|
||||
if j == 1 then
|
||||
nPreviousEdgeIndex = #BottomFaces[i].Edges
|
||||
end
|
||||
local nNextEdgeIndex = j + 1
|
||||
if j == #BottomFaces[i].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
|
||||
local CurrentEdge = {}
|
||||
CurrentEdge.idAdjacentFace = BottomFaces[i].Edges[j].Adj
|
||||
CurrentEdge.vtToolDirection = Vector3d( BottomFaces[i].Edges[j].Norm)
|
||||
CurrentEdge.dLength = BottomFaces[i].Edges[j].Len
|
||||
CurrentEdge.dElevation = BottomFaces[i].Edges[j].Elev
|
||||
CurrentEdge.bIsOpen = BottomFaces[i].Edges[j].Open
|
||||
CurrentEdge.bIsStartOpen = BottomFaces[i].Edges[nPreviousEdgeIndex].Open
|
||||
CurrentEdge.bIsEndOpen = BottomFaces[i].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'
|
||||
if j == nFirstLongEdgeIndex then
|
||||
BottomFaces[i].MainEdges.LongEdges[1] = CurrentEdge
|
||||
BottomFaces[i].MainEdges.LongEdges[1].Type = 'Long'
|
||||
elseif nNextEdgeIndex == nFirstLongEdgeIndex then
|
||||
BottomFaces[i].MainEdges.SideEdges[1] = CurrentEdge
|
||||
BottomFaces[i].MainEdges.SideEdges[1].Type = 'Side'
|
||||
elseif nPreviousEdgeIndex == nFirstLongEdgeIndex then
|
||||
BottomFaces[i].MainEdges.SideEdges[2] = CurrentEdge
|
||||
BottomFaces[i].MainEdges.SideEdges[2].Type = 'Side'
|
||||
else
|
||||
BottomFaces[i].MainEdges.LongEdges[2] = CurrentEdge
|
||||
BottomFaces[i].MainEdges.LongEdges[2].Type = 'Long'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return BottomFace
|
||||
return BottomFaces
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -285,7 +288,11 @@ local function GetLongFaces( Proc, MainFaces)
|
||||
error( 'GetLongFaces : Topology not implemented')
|
||||
end
|
||||
|
||||
local BottomFace = MainFaces.BottomFace or GetBottomFace( Proc)
|
||||
local BottomFace
|
||||
local BottomFaces = MainFaces.BottomFaces or GetBottomFaces( Proc)
|
||||
if BottomFaces and #BottomFaces > 0 then
|
||||
BottomFace = BottomFaces[1]
|
||||
end
|
||||
|
||||
local idFirstLongFace = GDB_ID.NULL
|
||||
local idSecondLongFace = GDB_ID.NULL
|
||||
@@ -375,7 +382,11 @@ local function GetSideFaces( Proc, MainFaces)
|
||||
error( 'GetSideFaces : Topology not implemented')
|
||||
end
|
||||
|
||||
local BottomFace = MainFaces.BottomFace or GetBottomFace( Proc)
|
||||
local BottomFace
|
||||
local BottomFaces = MainFaces.BottomFaces or GetBottomFaces( Proc)
|
||||
if BottomFaces and #BottomFaces > 0 then
|
||||
BottomFace = BottomFaces[1]
|
||||
end
|
||||
local LongFaces = MainFaces.LongFaces or GetLongFaces( Proc, MainFaces)
|
||||
|
||||
local idFirstSideFace = GDB_ID.NULL
|
||||
@@ -461,15 +472,17 @@ function FaceData.GetMainFaces( Proc, Part)
|
||||
MainFaces.TunnelAddedFaces = GetTunnelFaces( Proc, Part)
|
||||
end
|
||||
|
||||
MainFaces.BottomFace = GetBottomFace( Proc)
|
||||
MainFaces.BottomFaces = GetBottomFaces( Proc)
|
||||
MainFaces.LongFaces = GetLongFaces( Proc, MainFaces)
|
||||
MainFaces.SideFaces = GetSideFaces( Proc, MainFaces)
|
||||
-- TODO funzione apposita per informazioni log?
|
||||
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)
|
||||
if MainFaces.BottomFaces then
|
||||
for i = 1, #MainFaces.BottomFaces do
|
||||
EgtOutLog( 'Bottom Face : ' .. MainFaces.BottomFaces[i].id)
|
||||
end
|
||||
-- colore differente per la faccia di fondo principale
|
||||
EgtSurfTmSetFaceColor( Proc.id, MainFaces.BottomFaces[1].id, 1)
|
||||
end
|
||||
if MainFaces.LongFaces then
|
||||
for i = 1, #MainFaces.LongFaces do
|
||||
|
||||
Reference in New Issue
Block a user