diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index e42f737..5568d8f 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -82,6 +82,7 @@ function FaceData.GetFacesByAdjacencyNumber( Proc) local FacesByAdjacencyNumber = {} for i = 1, Proc.Fct do + -- TODO questo non funziona!! table.insert( FacesByAdjacencyNumber[#Proc.Faces[i].Adjacencies], i - 1) end @@ -92,6 +93,12 @@ end local function GetBottomFace( Proc) local BottomFace = {} + if Proc.Topology.Family == 'Tunnel' then + return BottomFace + elseif not ( Proc.FeatureTopology.Family == 'Rabbet' or Proc.FeatureTopology.Family == 'VGroove' or Proc.FeatureTopology.Family == 'Groove' or Proc.FeatureTopology.Family == 'Pocket') then + 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 local vFacesByAdjNumber = FaceData.GetFacesByAdjacencyNumber( Proc) local vBottomFace = vFacesByAdjNumber[ Proc.Fct - 1] @@ -123,27 +130,39 @@ local function GetBottomFace( Proc) end ------------------------------------------------------------------------------------------------------------- -local function GetLongFaces( Proc) +local function GetLongFaces( Proc, MainFaces) local LongFaces = {} if Proc.Fct > 5 then - error( 'GetLongFaces : More than 5 faces not supported') + error( 'GetLongFaces : Topology not implemented') end - local idBottomFace = GDB_ID.NULL - if Proc.MainFaces.BottomFace.Id then - idBottomFace = Proc.MainFaces.BottomFace.Id + local idBottomFace + if MainFaces.BottomFace then + idBottomFace = MainFaces.BottomFace.Id else local BottomFace = GetBottomFace( Proc) - idBottomFace = BottomFace.Id + idBottomFace = BottomFace.Id or GDB_ID.NULL end - -- facce adiacenti a quella di fondo, ordinate - local FacesAdjacentToBottom = GetAdjacentFaces( Proc, idBottomFace) - table.sort( FacesAdjacentToBottom, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) + local FacesToAnalyze = {} + for i = 1, Proc.Fct do + if Proc.Faces[i].Id ~= idBottomFace then + FacesToAnalyze[i] = Proc.Faces[i] + end + end + + + if Proc.FeatureTopology.Family == 'Tunnel' then + + else + -- facce adiacenti a quella di fondo, ordinate + FacesToAnalyze = GetAdjacentFaces( Proc, idBottomFace) + table.sort( FacesToAnalyze, function( a, b) return a.LengthOnMainFace > b.LengthOnMainFace end) + end -- la prima faccia lunga è sempre la prima della lista - LongFaces[1].Id = FacesAdjacentToBottom[1].Id + LongFaces[1].Id = FacesToAnalyze[1].Id -- si cerca l'eventuale seconda faccia lunga, ossia quella non adiacente alla prima if Proc.Fct > 3 then for i = 1, Proc.Fct do @@ -211,17 +230,9 @@ function FaceData.GetMainFaces( Proc) -- faccia di fondo if Proc.FeatureTopology.Family == 'Rabbet' or Proc.FeatureTopology.Family == 'VGroove' or Proc.FeatureTopology.Family == 'Groove' or Proc.FeatureTopology.Family == 'Pocket' then MainFaces.BottomFace = GetBottomFace( Proc) + MainFaces.LongFaces = GetLongFaces( Proc, MainFaces) end - -- facce lunghe - if Proc.FeatureTopology.Family == 'Rabbet' or Proc.FeatureTopology.Family == 'VGroove' or Proc.FeatureTopology.Family == 'Groove' or Proc.FeatureTopology.Family == 'Pocket' or Proc.FeatureTopology.Family == 'Tunnel' then - MainFaces.LongFaces = GetLongFaces( Proc) - end - - -- facce laterali - - - return MainFaces end