-- 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') -- Carico le librerie local WL = require( 'WallLib') 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 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 bResult = true end end --------------------------------------------------------------------- local function GetTriangularFaces( Proc) local vTriangularFaces = {} for i = 1, Proc.Fct do if WL.Is3EdgesApprox( Proc, i - 1) then table.insert( vTriangularFaces, i - 1) end end return vTriangularFaces end --------------------------------------------------------------------- local function GetFacesParallelToPart( Proc, sFamily) local vIsFaceParallel = {} 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 if i == vTriangularFaces[j] then bIsTriangularFace = true end end -- 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 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 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 end end end return vIsFaceParallel 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 = '' -- SE NON HA TUTTE LE FACCE PIANE RITORNARE NIL!! local bAllAnglesConcave bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( Proc) local vTriangularFaces = GetTriangularFaces( Proc) local bIsAnyFaceTriangular = #vTriangularFaces > 0 if Proc.Fct == 1 and IsAnyDimensionLongAsPart( Proc) then sFamily = 'Bevel' bIsThrough = true elseif Proc.Fct == 2 and bAllAnglesConcave and bIsAnyFaceTriangular then sFamily = 'Bevel' bIsThrough = false end local vIsFaceParallel = GetFacesParallelToPart( Proc, sFamily) for i = 1, #vIsFaceParallel do end if sFamily then sLongName = GetTopologyLongName( sFamily, bIsThrough, bAllRightAngles, bIsParallel, Proc.Fct) return sFamily, bIsThrough, bAllRightAngles, bIsParallel, sLongName else return nil end end ------------------------------------------------------------------------------------------------------------- return WFeatureTopology