Merge remote-tracking branch 'origin/feature/GetMainFaces' into feature/GetForcedStrategy
This commit is contained in:
+35
-95
@@ -9,15 +9,14 @@ local FeatureData = {}
|
||||
local BD = require( 'BeamData')
|
||||
|
||||
-- carico librerie
|
||||
local BL = require( 'BeamLib')
|
||||
local BeamLib = require( 'BeamLib')
|
||||
local FaceData = require( 'FaceData')
|
||||
local ID = require( 'Identity')
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- recupero topologia della feature
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function NeedTopologyFeature( Proc)
|
||||
-- richiedono calcolo topologia le feature tipo:
|
||||
if ID.IsCut( Proc) then
|
||||
return true
|
||||
elseif ID.IsDoubleCut( Proc) then
|
||||
@@ -44,41 +43,25 @@ local function NeedTopologyFeature( Proc)
|
||||
return true
|
||||
elseif ID.IsPocket( Proc) then
|
||||
return true
|
||||
elseif ID.IsMortise( Proc) and Proc.Fct < 6 then -- calcolo topologia SOLO se non raggiata -- TODO oppure riconoscerla come feature speciale
|
||||
-- calcolo topologia SOLO se non raggiata
|
||||
-- TODO oppure riconoscerla come feature speciale; valutare se controllare il numero di facce è un metodo efficace
|
||||
elseif ID.IsMortise( Proc) and Proc.Fct < 6 then
|
||||
return true
|
||||
elseif ID.IsFrontMortise( Proc) and Proc.Fct < 6 then -- calcolo topologia SOLO se non raggiata -- TODO oppure riconoscerla come feature speciale
|
||||
-- calcolo topologia SOLO se non raggiata
|
||||
-- TODO oppure riconoscerla come feature speciale; valutare se controllare il numero di facce è un metodo efficace
|
||||
elseif ID.IsFrontMortise( Proc) and Proc.Fct < 6 then
|
||||
return true
|
||||
end
|
||||
-- tutte le altre non richiedono calcolo topologia
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce la matrice delle adiacenze di Proc dove i e j sono le facce e a(ij) è l'angolo tra di esse; 0 se nessuna adiacenza
|
||||
local function GetAdjacencyMatrix( Proc)
|
||||
local vAdj = {}
|
||||
-- essendo la matrice simmetrica a diagonale nulla, ne calcolo solo la metà superiore
|
||||
for i = 1, Proc.Fct do
|
||||
vAdj[i] = {}
|
||||
for j = i + 1, Proc.Fct do
|
||||
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT)
|
||||
if not vAdj[i][j] then vAdj[i][j] = 0 end
|
||||
end
|
||||
end
|
||||
-- riempio di conseguenza il resto della matrice
|
||||
for i = 1, Proc.Fct do
|
||||
vAdj[i][i] = 0
|
||||
for j = i + 1, Proc.Fct do
|
||||
vAdj[j][i] = vAdj[i][j]
|
||||
end
|
||||
end
|
||||
return vAdj
|
||||
-- se feature non tra quelle sopra, riconoscimento topologico non necessario
|
||||
return false
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce true se Proc ha tutti gli angoli concavi (bAllConcave) e, nei casi in cui ha senso, se questi sono esattamente 90 deg (bAllRight)
|
||||
local function AreAllAnglesConcaveOrRight( vAdj)
|
||||
local bAllConcave, bAllRight = true, true
|
||||
|
||||
local nFct = #( vAdj or {})
|
||||
for i = 1, nFct do
|
||||
for j = 1, nFct do
|
||||
@@ -92,6 +75,7 @@ local function AreAllAnglesConcaveOrRight( vAdj)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- se 1 faccia oppure 2 facce con angolo convesso non ha senso ritornare valori per bAllRight
|
||||
if nFct < 2 or ( nFct == 2 and vAdj[1][2] > 0) then
|
||||
return bAllConcave
|
||||
@@ -100,17 +84,6 @@ local function AreAllAnglesConcaveOrRight( vAdj)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- retituisce un vettore con gli indici (0 based) delle facce triangolari (o quasi) di Proc
|
||||
local function GetTriangularFaces( Proc)
|
||||
local vTriangularFaces = {}
|
||||
for i = 1, Proc.Fct do
|
||||
if BL.Is3EdgesApprox( Proc, i - 1) then
|
||||
table.insert( vTriangularFaces, i - 1)
|
||||
end
|
||||
end
|
||||
return vTriangularFaces
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce true se almeno una delle dimensioni della feature è maggiore o uguale ad una delle dimensioni principali del pezzo (tolleranza 1 mm)
|
||||
@@ -118,37 +91,14 @@ local function IsAnyDimensionLongAsPart( Proc)
|
||||
local bResult = false
|
||||
local nBoxSolidId = EgtGetFirstNameInGroup( Proc.PartId or GDB_ID.NULL, 'Box')
|
||||
local b3Solid = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD)
|
||||
|
||||
if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or
|
||||
Proc.Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or
|
||||
Proc.Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then
|
||||
bResult = true
|
||||
end
|
||||
return bResult
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce gli id delle facce di Proc che hanno il numero di adiacenze nAdj
|
||||
local function GetFacesWithGivenAdjacencyNumber( Proc, vAdj)
|
||||
if not vAdj then vAdj = GetAdjacencyMatrix( Proc) end
|
||||
local nFct = #( vAdj or {})
|
||||
local vFacesWithAdj = {}
|
||||
vFacesWithAdj[1] = {}
|
||||
vFacesWithAdj[2] = {}
|
||||
vFacesWithAdj[3] = {}
|
||||
vFacesWithAdj[4] = {}
|
||||
vFacesWithAdj[5] = {}
|
||||
for i = 1, nFct do
|
||||
local nAdjCount = 0
|
||||
for j = 1, nFct do
|
||||
if vAdj[i][j] and vAdj[i][j] ~= 0 and i ~= j then
|
||||
nAdjCount = nAdjCount + 1
|
||||
end
|
||||
end
|
||||
if nAdjCount > 0 then
|
||||
table.insert( vFacesWithAdj[nAdjCount], i - 1)
|
||||
end
|
||||
end
|
||||
return vFacesWithAdj
|
||||
return bResult
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
@@ -170,23 +120,22 @@ end
|
||||
local function GetTopologyName( sFamily, nNumberOfFaces, bIsThrough)
|
||||
return sFamily .. '-' .. tostring( nNumberOfFaces) .. '-' .. EgtIf( bIsThrough, 'Through', 'Blind')
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- recupera topologia feature
|
||||
local function ClassifyTopology( Proc, b3Raw)
|
||||
local FeatureTopology = {}
|
||||
|
||||
-- calcoli
|
||||
if not Proc.AffectedFaces then Proc.AffectedFaces = BL.GetProcessAffectedFaces( Proc) end
|
||||
if not Proc.AffectedFaces then Proc.AffectedFaces = BeamLib.GetProcessAffectedFaces( Proc) end
|
||||
|
||||
local vAdj = GetAdjacencyMatrix( Proc)
|
||||
local vAdj = FaceData.GetAdjacencyMatrix( Proc)
|
||||
local bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( vAdj)
|
||||
local vTriangularFaces = GetTriangularFaces( Proc)
|
||||
local vTriangularFaces = FaceData.GetTriangularFaces( Proc)
|
||||
local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc)
|
||||
local vFacesWithAdjNumber = GetFacesWithGivenAdjacencyNumber( Proc, vAdj)
|
||||
local vFacesByAdjNumber = FaceData.GetFacesByAdjacencyNumber( Proc)
|
||||
local bIsFeatureCuttingEntireSection = IsFeatureCuttingEntireSection( Proc.Box, b3Raw)
|
||||
local bIsFeatureCuttingEntireLength = IsFeatureCuttingEntireLength( Proc.Box, b3Raw)
|
||||
|
||||
-- assegnazione tipologia
|
||||
local sFamily
|
||||
local bIsThrough
|
||||
if Proc.Fct == 1 and ( bIsFeatureCuttingEntireSection or bIsFeatureCuttingEntireLength) then
|
||||
@@ -201,52 +150,52 @@ local function ClassifyTopology( Proc, b3Raw)
|
||||
sFamily = 'Rabbet'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave then
|
||||
sFamily = 'V-Groove'
|
||||
sFamily = 'VGroove'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'DoubleBevel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithAdjNumber[2] == 1 and #vTriangularFaces == 2 then
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and #vTriangularFaces == 2 then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithAdjNumber[2] == 1 and bIsAnyDimensionLongAsPart then
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 1 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithAdjNumber[2] == 3 then
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 3 then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 4 and #vFacesWithAdjNumber[2] == 4 and #vTriangularFaces == 2 then
|
||||
elseif Proc.Fct == 4 and #vFacesByAdjNumber[2] == 4 and #vTriangularFaces == 2 then
|
||||
sFamily = 'DoubleBevel'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesWithAdjNumber[3] == 2 then
|
||||
elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[3] == 2 then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesWithAdjNumber[2] == 4 and bIsAnyDimensionLongAsPart then
|
||||
elseif Proc.Fct == 4 and bAllAnglesConcave and #vFacesByAdjNumber[2] == 4 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Tunnel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct >= 4 and #vFacesWithAdjNumber[1] == 2 and bIsAnyDimensionLongAsPart then
|
||||
elseif Proc.Fct >= 4 and #vFacesByAdjNumber[1] == 2 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Strip'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 5 and bAllAnglesConcave and #vFacesWithAdjNumber[4] == 1 then
|
||||
elseif Proc.Fct == 5 and bAllAnglesConcave and #vFacesByAdjNumber[4] == 1 then
|
||||
sFamily = 'Pocket'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 6 and #vFacesWithAdjNumber[2] == 4 and #vFacesWithAdjNumber[3] == 2 and #vTriangularFaces == 4 then
|
||||
elseif Proc.Fct == 6 and #vFacesByAdjNumber[2] == 4 and #vFacesByAdjNumber[3] == 2 and #vTriangularFaces == 4 then
|
||||
sFamily = 'DoubleBevel'
|
||||
bIsThrough = false
|
||||
end
|
||||
|
||||
-- assegnazioni
|
||||
if sFamily then
|
||||
FeatureTopology.Family = sFamily
|
||||
FeatureTopology.IsThrough = bIsThrough
|
||||
FeatureTopology.AllRightAngles = bAllRightAngles
|
||||
FeatureTopology.Name = GetTopologyName( sFamily, Proc.Fct, bIsThrough)
|
||||
FeatureTopology.vAdj = vAdj
|
||||
FeatureTopology.AdjacencyMatrix = vAdj
|
||||
-- feature che necessita di essere catalogata, ma non si capisce come
|
||||
else
|
||||
FeatureTopology.Family = 'NOT_IMPLEMENTED'
|
||||
FeatureTopology.Name = FeatureTopology.Family
|
||||
end
|
||||
|
||||
return FeatureTopology
|
||||
end
|
||||
|
||||
@@ -257,7 +206,6 @@ function FeatureData.GetTopology( Proc, b3Raw)
|
||||
-- calcolo topologia solo se necessario, altrimenti si sfruttano le informazioni della feature BTL
|
||||
if NeedTopologyFeature( Proc) then
|
||||
FeatureTopology = ClassifyTopology( Proc, b3Raw)
|
||||
-- se non richiesto, setto 'FEATURE'
|
||||
else
|
||||
FeatureTopology.Family = 'FEATURE'
|
||||
FeatureTopology.Name = FeatureTopology.Family
|
||||
@@ -266,19 +214,11 @@ function FeatureData.GetTopology( Proc, b3Raw)
|
||||
return FeatureTopology
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- recupero facce principali della feature, in base alla topologia
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function FeatureData.GetMainFaces( Proc, b3Raw)
|
||||
local MainFaces = {}
|
||||
|
||||
return MainFaces
|
||||
end
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- Recupero dati foro e adattamento se speciale
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function FeatureData.GetDataDrill( Proc)
|
||||
function FeatureData.GetDrillingData( Proc)
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i')
|
||||
|
||||
-- verifico se foro da adattare
|
||||
if EgtExistsInfo( Proc.Id, 'DiamUser') then
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
@@ -286,12 +226,12 @@ function FeatureData.GetDataDrill( Proc)
|
||||
EgtModifyArcRadius( AuxId, BD.USER_HOLE_DIAM / 2)
|
||||
end
|
||||
end
|
||||
-- recupero diametro e lunghezza
|
||||
|
||||
local dDiam = EgtGetInfo( Proc.Id, 'P12', 'd') or 0
|
||||
local dLen = abs( EgtCurveThickness( Proc.Id + AuxId)) or 0
|
||||
-- recupero faccia di entrata e uscita
|
||||
local nFcs = EgtGetInfo( Proc.Id, 'FCS', 'i') or 0
|
||||
local nFce = EgtGetInfo( Proc.Id, 'FCE', 'i') or 0
|
||||
|
||||
return dDiam, dLen, nFcs, nFce
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user