- alcune correzioni a Topology
- aggiunto riconoscimento topologie fino a 5 lati (da testare)
This commit is contained in:
@@ -13,7 +13,7 @@ local WL = require( 'WallLib')
|
||||
EgtOutLog( ' WFeatureTopology started', 1)
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetAdjacencyMatrix(Proc )
|
||||
local function GetAdjacencyMatrix( Proc)
|
||||
local vAdj = {}
|
||||
for i = 1, Proc.Fct do
|
||||
vAdj[i] = {}
|
||||
@@ -22,6 +22,7 @@ local function GetAdjacencyMatrix(Proc )
|
||||
vAdj[i][j] = 0
|
||||
else
|
||||
_, _, _, 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
|
||||
j = j + 1
|
||||
end
|
||||
@@ -30,13 +31,32 @@ local function GetAdjacencyMatrix(Proc )
|
||||
return vAdj
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- restituisce gli id delle facce di Proc che hanno il numero di adiacenze nAdj
|
||||
local function GetFacesWithGivenAdjacencyNumber( Proc, nAdj)
|
||||
local vAdj = GetAdjacencyMatrix( Proc)
|
||||
local vFacesWithGivenAdj = {}
|
||||
for i = 1, Proc.Fct do
|
||||
local nAdjCount = 0
|
||||
for j = 1, Proc.Fct do
|
||||
if vAdj[i][j] and vAdj[i][j] ~= 0 then
|
||||
nAdjCount = nAdjCount + 1
|
||||
end
|
||||
end
|
||||
if nAdjCount == nAdj then
|
||||
table.insert( vFacesWithGivenAdj, i - 1)
|
||||
end
|
||||
end
|
||||
return vFacesWithGivenAdj
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function AreAllAnglesConcaveOrRight( Proc)
|
||||
if Proc.Fct < 2 then return nil end
|
||||
local vAdj = GetAdjacencyMatrix( Proc)
|
||||
local bAllConcave, bAllRight = true, true
|
||||
for i = 1, Proc.Fct do
|
||||
for j = 1, Proc.Fct do
|
||||
-- se trovo un angolo convesso restituisco falso e esco subito
|
||||
if vAdj[i][j] and vAdj[i][j] > 0 then
|
||||
bAllConcave = false
|
||||
bAllRight = false
|
||||
@@ -46,11 +66,16 @@ local function AreAllAnglesConcaveOrRight( Proc)
|
||||
end
|
||||
end
|
||||
end
|
||||
return bAllConcave, bAllRight
|
||||
-- se 1 faccia oppure 2 facce con angolo convesso non ha senso ritornare valori per bAllRight
|
||||
if Proc.Fct < 2 or ( Proc.Fct == 2 and vAdj[1][2] > 0) then
|
||||
return bAllConcave
|
||||
else
|
||||
return bAllConcave, bAllRight
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function IsAnyDimensionLongAsPart( Proc )
|
||||
local function IsAnyDimensionLongAsPart( Proc)
|
||||
local bResult = false
|
||||
local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD)
|
||||
if Proc.Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or
|
||||
@@ -77,7 +102,7 @@ local function GetFacesParallelToPart( Proc, sFamily)
|
||||
local vFacesParallelToPart = {}
|
||||
for i = 0, Proc.Fct - 1 do
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT)
|
||||
if sFamily == 'Bevel' then
|
||||
if sFamily == 'Bevel' or sFamily == 'DoubleBevel' then
|
||||
local vTriangularFaces = GetTriangularFaces( Proc)
|
||||
local bIsTriangularFace = false
|
||||
-- verifico se la faccia è triangolare
|
||||
@@ -93,7 +118,7 @@ local function GetFacesParallelToPart( Proc, sFamily)
|
||||
end
|
||||
-- altrimenti deve avere una componente della normale nulla
|
||||
else
|
||||
if vtN:getX() < 10 * GEO.EPS_SMALL or vtN:getY() < 10 * GEO.EPS_SMALL or vtN:getZ() < 10 * GEO.EPS_SMALL then
|
||||
if abs( vtN:getX()) < 10 * GEO.EPS_SMALL or abs( vtN:getY()) < 10 * GEO.EPS_SMALL or abs( vtN:getZ()) < 10 * GEO.EPS_SMALL then
|
||||
table.insert( vFacesParallelToPart, i)
|
||||
end
|
||||
end
|
||||
@@ -136,17 +161,43 @@ function WFeatureTopology.Classify( Proc)
|
||||
local bAllAnglesConcave
|
||||
bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc)
|
||||
local vTriangularFaces = GetTriangularFaces( Proc)
|
||||
local bIsAnyFaceTriangular = #vTriangularFaces > 0
|
||||
local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc)
|
||||
if Proc.Fct == 1 and bIsAnyDimensionLongAsPart then
|
||||
local vFacesWithTwoAdj = GetFacesWithGivenAdjacencyNumber( Proc, 2)
|
||||
local vFacesWithThreeAdj = GetFacesWithGivenAdjacencyNumber( Proc, 3)
|
||||
local vFacesWithFourAdj = GetFacesWithGivenAdjacencyNumber( Proc, 4)
|
||||
|
||||
if Proc.IsOutline then
|
||||
sFamily = 'OUTLINE'
|
||||
elseif Proc.Fct == 1 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave and #vTriangularFaces == 1 then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Rabbet'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 2 and not bAllAnglesConcave and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'DoubleBevel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 1 and #vTriangularFaces == 2 then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 1 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 3 and bAllAnglesConcave and #vFacesWithTwoAdj == 3 then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 4 and #vFacesWithThreeAdj == 2 then
|
||||
sFamily = 'Groove'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 4 and #vFacesWithTwoAdj == 4 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Tunnel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 5 and #vFacesWithFourAdj == 1 then
|
||||
sFamily = 'Tunnel'
|
||||
bIsThrough = false
|
||||
end
|
||||
local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily)
|
||||
bIsParallel = ( #vFacesParallelToPart == Proc.Fct)
|
||||
|
||||
@@ -309,9 +309,9 @@ local function PrintFeatures( vProc)
|
||||
EgtOutLog( ' *** Feature List ***')
|
||||
for i = 1, #vProc do
|
||||
local Proc = vProc[i]
|
||||
local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s',
|
||||
local sOut = string.format( 'Part=%3d Proc=%3d Grp=%1d Prc=%3d TC=%2d/%d Flg=%2d Fcse=%1d,%1d Diam=%.2f Fct=%2d Dbl=%2d Dlt=%.1f Box=%s TopoName=%s',
|
||||
Proc.PartId, Proc.Id, Proc.Grp, Proc.Prc, Proc.TaskId, Proc.CutId,
|
||||
Proc.Flg, Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box))
|
||||
Proc.Flg, Proc.Fcs, Proc.Fce, Proc.Diam, Proc.Fct, Proc.Double or 0, Proc.Delta or 0, tostring( Proc.Box), Proc.TopologyLongName or '')
|
||||
EgtOutLog( sOut)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user