- riconoscimento bevel e rabbet funzionanti; da testare
This commit is contained in:
@@ -16,11 +16,12 @@ EgtOutLog( ' WFeatureTopology started', 1)
|
||||
local function GetAdjacencyMatrix(Proc )
|
||||
local vAdj = {}
|
||||
for i = 1, Proc.Fct do
|
||||
vAdj[i] = {}
|
||||
for j = 1, Proc.Fct do
|
||||
if i ~= j then
|
||||
if i == j then
|
||||
vAdj[i][j] = 0
|
||||
else
|
||||
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i, j, GDB_ID.ROOT)
|
||||
_, _, _, vAdj[i][j] = EgtSurfTmFacetsContact( Proc.Id, i - 1, j - 1, GDB_ID.ROOT)
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
@@ -31,6 +32,7 @@ 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
|
||||
@@ -39,7 +41,7 @@ local function AreAllAnglesConcaveOrRight( Proc)
|
||||
bAllConcave = false
|
||||
bAllRight = false
|
||||
break
|
||||
elseif vAdj[i][j] and vAdj[i][j] + 90 > GEO.EPS_SMALL then
|
||||
elseif vAdj[i][j] and vAdj[i][j] ~= 0 and vAdj[i][j] + 90 > GEO.EPS_SMALL then
|
||||
bAllRight = false
|
||||
end
|
||||
end
|
||||
@@ -51,11 +53,12 @@ end
|
||||
local function IsAnyDimensionLongAsPart( Proc )
|
||||
local bResult = false
|
||||
local b3Solid = EgtGetBBoxGlob( Proc.PartId, GDB_BB.STANDARD)
|
||||
if Proc.Box:getDimX() > b3Solid:getDimX() - 10 * GEO.EPS_SMALL or
|
||||
Proc.Box:getDimY() > b3Solid:getDimY() - 10 * GEO.EPS_SMALL or
|
||||
Proc.Box:getDimZ() > b3Solid:getDimZ() - 10 * GEO.EPS_SMALL then
|
||||
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
|
||||
|
||||
---------------------------------------------------------------------
|
||||
@@ -71,14 +74,14 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetFacesParallelToPart( Proc, sFamily)
|
||||
local vIsFaceParallel = {}
|
||||
local vFacesParallelToPart = {}
|
||||
for i = 0, Proc.Fct - 1 do
|
||||
local vtN = EgtSurfTmFacetNormVersor( Proc.Id, i, GDB_ID.ROOT)
|
||||
if sFamily == 'Bevel' then
|
||||
local vTriangularFaces = GetTriangularFaces( Proc)
|
||||
local bIsTriangularFace = false
|
||||
-- verifico se la faccia è triangolare
|
||||
for j = 0, #vTriangularFaces do
|
||||
for j = 1, #vTriangularFaces do
|
||||
if i == vTriangularFaces[j] then
|
||||
bIsTriangularFace = true
|
||||
end
|
||||
@@ -86,42 +89,43 @@ local function GetFacesParallelToPart( Proc, sFamily)
|
||||
-- se faccia triangolare deve avere la normale parallela ad una direzione principale
|
||||
if bIsTriangularFace then
|
||||
if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
vIsFaceParallel[i] = true
|
||||
table.insert( vFacesParallelToPart, i)
|
||||
end
|
||||
-- altrimenti deve avere una componente della normale nulla
|
||||
else
|
||||
if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then
|
||||
vIsFaceParallel[i] = true
|
||||
if vtN:getX() < 10 * GEO.EPS_SMALL or vtN:getY() < 10 * GEO.EPS_SMALL or vtN:getZ() < 10 * GEO.EPS_SMALL then
|
||||
table.insert( vFacesParallelToPart, i)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- la normale deve essere parallela alla direzione principale
|
||||
if vtN:getX():isSmall() or vtN:getY():isSmall() or vtN:getZ():isSmall() then
|
||||
vIsFaceParallel[i] = true
|
||||
-- la normale deve essere parallela ad una direzione principale
|
||||
if AreSameOrOppositeVectorApprox( vtN, X_AX()) or AreSameOrOppositeVectorApprox( vtN, Y_AX()) or AreSameOrOppositeVectorApprox( vtN, Z_AX()) then
|
||||
table.insert( vFacesParallelToPart, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
return vIsFaceParallel
|
||||
return vFacesParallelToPart
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, nNumberOfFaces)
|
||||
-- feature passante o cieca
|
||||
local sThrough = '_'
|
||||
if bIsThrough ~= nil then EgtIf( bIsThrough, 'Through', 'Blind') end
|
||||
if bIsThrough ~= nil then sThrough = 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
|
||||
if bAllRightAngles ~= nil then sAllRightAngles = 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
|
||||
if bIsParallel ~= nil then sParallel = EgtIf( bIsParallel, 'Parallel', 'NotParallel') end
|
||||
|
||||
local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. nNumberOfFaces
|
||||
local sLongName = sFamily .. '-' .. sThrough .. '-' .. sAllRightAngles .. '-' .. sParallel .. '-' .. nNumberOfFaces
|
||||
return sLongName
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
function WFeatureTopology.Bevel( Proc)
|
||||
function WFeatureTopology.Classify( Proc)
|
||||
local bRecognized = false
|
||||
local sFamily
|
||||
local bIsThrough
|
||||
local bAllRightAngles
|
||||
@@ -133,24 +137,27 @@ function WFeatureTopology.Bevel( Proc)
|
||||
bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc)
|
||||
local vTriangularFaces = GetTriangularFaces( Proc)
|
||||
local bIsAnyFaceTriangular = #vTriangularFaces > 0
|
||||
if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then
|
||||
local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc)
|
||||
if Proc.Fct == 1 and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = true
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then
|
||||
sFamily = 'Bevel'
|
||||
bIsThrough = false
|
||||
elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyDimensionLongAsPart then
|
||||
sFamily = 'Rabbet'
|
||||
bIsThrough = true
|
||||
end
|
||||
local vIsFaceParallel = GetFacesParallelToPart( Proc, sFamily)
|
||||
for i = 1, #vIsFaceParallel do
|
||||
|
||||
end
|
||||
local vFacesParallelToPart = GetFacesParallelToPart( Proc, sFamily)
|
||||
bIsParallel = ( #vFacesParallelToPart == Proc.Fct)
|
||||
|
||||
if sFamily then
|
||||
sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct)
|
||||
return sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName
|
||||
else
|
||||
return nil
|
||||
Proc.Topology, Proc.IsThrough, Proc.AllRightAngles, Proc.IsParallel, Proc.TopologyLongName = sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName
|
||||
bRecognized = true
|
||||
end
|
||||
|
||||
return bRecognized
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -23,6 +23,7 @@ if WALL and WALL.NESTINGCORNERBL then WD.NESTING_CORNER = 'BL' end
|
||||
-- Carico le librerie
|
||||
_G.package.loaded.WMachiningLib = nil
|
||||
_G.package.loaded.WallLib = nil
|
||||
_G.package.loaded.WFeatureTopology = nil
|
||||
_G.package.loaded.WProcessCut = nil
|
||||
_G.package.loaded.WProcessDoubleCut = nil
|
||||
_G.package.loaded.WProcessSawCut = nil
|
||||
@@ -36,6 +37,7 @@ _G.package.loaded.WProcessFreeContour = nil
|
||||
_G.package.loaded.WProcessVariant = nil
|
||||
local WM = require( 'WMachiningLib')
|
||||
local WL = require( 'WallLib')
|
||||
local Topology = require( 'WFeatureTopology')
|
||||
local Cut = require( 'WProcessCut')
|
||||
local DoubleCut = require( 'WProcessDoubleCut')
|
||||
local SawCut = require( 'WProcessSawCut')
|
||||
@@ -289,6 +291,19 @@ local function ClassifyFeatures( vProc, b3Raw)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function ClassifyTopology( vProc)
|
||||
local nRecognized = 0
|
||||
for i = 1, #vProc do
|
||||
local Proc = vProc[i]
|
||||
if Topology.Classify( Proc) then
|
||||
nRecognized = nRecognized + 1
|
||||
end
|
||||
end
|
||||
|
||||
return nRecognized
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
local function PrintFeatures( vProc)
|
||||
EgtOutLog( ' *** Feature List ***')
|
||||
@@ -699,6 +714,8 @@ function WallExec.ProcessFeatures()
|
||||
local vPartProc = WallExec.CollectFeatures( vPart[i].Id, b3Raw)
|
||||
vProc = EgtJoinTables( vProc, vPartProc)
|
||||
end
|
||||
-- classifico topologicamente le feature
|
||||
ClassifyTopology( vProc)
|
||||
-- classifico le feature
|
||||
ClassifyFeatures( vProc, b3Raw)
|
||||
-- Eventuale determinazione delle feature lavorabili in parallelo (implementata nella configurazione macchina)
|
||||
|
||||
Reference in New Issue
Block a user