5bb7fdd634
- spostate alcune funzioni da FreeContour a WallLib
130 lines
3.4 KiB
Lua
130 lines
3.4 KiB
Lua
-- WFeatureTopology.lua by Egaltech s.r.l. 2023/06/23
|
|
-- Libreria per classificazione topologica feature pareti
|
|
|
|
-- Tabella per definizione modulo
|
|
local WFeatureTopology = {}
|
|
|
|
-- Include
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' WFeatureTopology started', 1)
|
|
|
|
---------------------------------------------------------------------
|
|
local function GetAdjacencyMatrix(Proc )
|
|
local vAdj = {}
|
|
for i = 1, Proc.Fct do
|
|
for j = 1, Proc.Fct do
|
|
if i ~= j then
|
|
vAdj[i][j] = 0
|
|
else
|
|
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i, j, GDB_ID.ROOT)
|
|
end
|
|
j = j + 1
|
|
end
|
|
i = i + 1
|
|
end
|
|
return vAdj
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
local function AreAllAnglesConcaveOrRight( Proc)
|
|
local vAdj = GetAdjacencyMatrix( Proc)
|
|
local bAllConcave, bAllRight = true, true
|
|
for i = 1, Proc.Fct do
|
|
for j = 1, Proc.Fct do
|
|
if vAdj[i][j] and vAdj[i][j] > 0 then
|
|
bAllConcave = false
|
|
bAllRight = false
|
|
break
|
|
elseif vAdj[i][j] and vAdj[i][j] + 90 > GEO.EPS_SMALL then
|
|
bAllRight = false
|
|
end
|
|
end
|
|
end
|
|
return bAllConcave, bAllRight
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, nNumberOfFaces)
|
|
-- feature passante o cieca
|
|
local sThrough = '_'
|
|
if bIsThrough ~= nil then EgtIf( bIsThrough, 'Through', 'Blind') end
|
|
-- tutti gli angoli della feature sono retti oppure no
|
|
local sAllRightAngles = '_'
|
|
if bAllRightAngles ~= nil then EgtIf( bAllRightAngles, 'RightAngles', 'NotRightAngles') end
|
|
-- tutte le dimensioni della feature sono parallele agli assi principali del pezzo oppure no
|
|
local sParallel = '_'
|
|
if bIsParallel ~= nil then EgtIf( bIsParallel, 'Parallel', 'NotParallel') end
|
|
|
|
local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. nNumberOfFaces
|
|
return sLongName
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
function WFeatureTopology.Bevel( Proc)
|
|
local sFamily
|
|
local bIsThrough
|
|
local bAllRightAngles
|
|
local bIsParallel
|
|
local sLongName = ''
|
|
|
|
local bAllAnglesConcave
|
|
bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc)
|
|
if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then
|
|
sFamily = 'Bevel'
|
|
bIsThrough = true
|
|
elseif Proc.Fct == 2 and bAllAnglesConcave and ( not IsAnyDimensionLongAsPart( Proc) or IsOneFaceTriangular( Proc)) then
|
|
sFamily = 'Bevel'
|
|
bIsThrough = false
|
|
end
|
|
bIsParallel = IsFeatureParallelToPart( Proc, sFamily)
|
|
|
|
if sFamily then
|
|
sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct)
|
|
return sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
|
|
function WFeatureTopology.ClassifyTopology( Proc)
|
|
local sTopologicalName
|
|
if Proc.Fct == 1 then
|
|
if IsAnyDimensionLongAsPart( Proc) then
|
|
sTopologicalName = 'Bevel_Through___Parallel_1'
|
|
end
|
|
elseif Proc.Fct == 2 then
|
|
if vAdj[1][1] and abs( vAdj[1][1] - 90) < GEO.EPS_SMALL then
|
|
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
return WFeatureTopology |