648 lines
21 KiB
Lua
648 lines
21 KiB
Lua
-- EgtLib.lua libreria di base EgalTech per Lua 2022/04/12
|
|
-- 2019/12/04 EgtTestBreak interruzione se valore 1.
|
|
-- 2020/06/04 Aggiunta funzione EgtCurveIsACircle.
|
|
-- 2020/06/16 Aggiunta funzione EgtSurfTmGetFacetBBoxRef.
|
|
-- 2021/11/27 Aggiunta funzione EgtClamp.
|
|
-- 2022/04/12 Aggiunta funzione EgtGetValInNotes.
|
|
|
|
-- Tavola per definizione modulo (serve ma non usata)
|
|
local EgtBase = {}
|
|
|
|
EgtOutLog( 'EgtBase started', 1)
|
|
|
|
-- Funzioni del package matematico rese globali e con angoli in gradi
|
|
abs = math.abs
|
|
fmod = math.fmod
|
|
floor = math.floor
|
|
ceil = math.ceil
|
|
min = math.min
|
|
max = math.max
|
|
huge = math.huge
|
|
modf = math.modf
|
|
sqrt = math.sqrt
|
|
pow = function( x, y) return x ^ y end
|
|
exp = math.exp
|
|
log = math.log
|
|
log10 = function( x) return math.log( x, 10) end
|
|
ldexp = function( x, exp) return x * 2.0 ^ exp end
|
|
deg = math.deg
|
|
rad = math.rad
|
|
pi = math.pi
|
|
sin = function( x) return math.sin( math.rad( x)) end
|
|
cos = function( x) return math.cos( math.rad( x)) end
|
|
tan = function( x) return math.tan( math.rad( x)) end
|
|
asin = function( x) return math.deg( math.asin( x)) end
|
|
acos = function( x) return math.deg( math.acos( x)) end
|
|
atan = function( y, x) return math.deg( math.atan( y, x)) end
|
|
atan2 = function( y, x) return math.deg( math.atan( y, x)) end
|
|
random = math.random
|
|
randomseed = math.randomseed
|
|
tointeger = math.tointeger
|
|
|
|
----------------------------------------------------------------------------
|
|
function EgtIf( bCond, Val1, Val2)
|
|
if bCond then
|
|
return Val1
|
|
else
|
|
return Val2
|
|
end
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
function EgtClamp( Val, Min, Max)
|
|
if Min > Max then
|
|
Min, Max = Max, Min
|
|
end
|
|
if Val < Min then
|
|
return Min
|
|
elseif Val > Max then
|
|
return Max
|
|
else
|
|
return Val
|
|
end
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per protezione variabili e funzioni globali
|
|
function EgtProtectGlobal()
|
|
local newgt = {}
|
|
setmetatable( newgt, {__index = _G,
|
|
__newindex = function( t, k, v)
|
|
local k3 = string.sub( k, 1, 3)
|
|
if k3 == 'Egt' or k3 == 'Emt' or
|
|
k3 == 'GEO' or k3 == 'GDB' or k3 == 'SCE' or k3 == 'MCH' then
|
|
error( "attempting to change global "..tostring( k)..' to '..tostring( v), 2)
|
|
else
|
|
rawset( t, k, v)
|
|
end
|
|
end
|
|
})
|
|
return newgt
|
|
end
|
|
|
|
-- Funzione per lancio, se richiesta, predisposizione debug
|
|
function EgtEnableDebug( bOn)
|
|
if not bOn then
|
|
EgtOutLog( 'Release Mode', 1)
|
|
return true
|
|
elseif EgtIs64bit() then
|
|
-- non funziona a 64 bit
|
|
EgtOutLog( 'Skipped Debug Activation (64bit)')
|
|
return false
|
|
else
|
|
-- carico il modulo opportuno
|
|
EgtOutLog( 'Debug Mode (32bit)', 1)
|
|
return require( 'mobdebug').start()
|
|
end
|
|
end
|
|
|
|
-- Funzione per reset librerie
|
|
function EgtResetLibs()
|
|
package.loaded.EgtTest = nil
|
|
package.loaded.EgtBase = nil
|
|
package.loaded.EgtConst = nil
|
|
package.loaded.EgtVector3d = nil
|
|
package.loaded.EgtPoint3d = nil
|
|
package.loaded.EgtFrame3d = nil
|
|
package.loaded.EgtBBox3d = nil
|
|
package.loaded.EgtColor3d = nil
|
|
package.loaded.Dimension = nil
|
|
package.loaded.EgtLinearDimension = nil
|
|
package.loaded.EmtGenerator = nil
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per OutLog di tutte le variabili globali
|
|
function EgtOutLogAllGlobVars()
|
|
local a = {}
|
|
for k,v in pairs( _G) do
|
|
a[#a+1] = k .. " => ".. tostring( v)
|
|
end
|
|
table.sort( a)
|
|
EgtOutLog( 'Global Variables (#' .. #a .. ') :')
|
|
for _,v in ipairs( a) do
|
|
EgtOutLog( v)
|
|
end
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per avere direttorio del file che lancia la funzione
|
|
function EgtGetSourceDir( nUp)
|
|
local nSou = 2
|
|
if nUp then nSou = nSou + nUp end
|
|
local info = debug.getinfo( nSou, 'S')
|
|
local dir = info.source:match("^@?(.-)([^\\/]-%.?([^%.\\/]*))$")
|
|
return dir
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per avere direttorio e file che lancia la funzione
|
|
function EgtGetSourcePath( nUp)
|
|
local nSou = 2
|
|
if nUp then nSou = nSou + nUp end
|
|
local info = debug.getinfo( nSou, 'S')
|
|
local dir = string.gsub( info.source, '@', '')
|
|
return dir
|
|
end
|
|
|
|
-- Funzione per accodare path di ricerca librerie lua
|
|
function EgtAddToPackagePath( path)
|
|
if not package.path:find( path, 1, true) then
|
|
if package.path:sub( -1) == ';' then
|
|
package.path = package.path .. path .. ';'
|
|
else
|
|
package.path = package.path .. ';' .. path .. ';'
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Funzione per rimuovere direttori macchine da path di ricerca librerie lua
|
|
function EgtRemoveBaseMachineDirFromPackagePath()
|
|
local vLibDir = EgtSplitString( _G.package.path, ';')
|
|
if not vLibDir or #vLibDir == 0 then return end
|
|
local sBaseMachDir = EgtSplitPath( EgtGetCurrMachineDir() or '')
|
|
if not sBaseMachDir or #sBaseMachDir == 0 then return end
|
|
package.path = ''
|
|
for i = 1, #vLibDir do
|
|
if #vLibDir[i] > 0 and not vLibDir[i]:find( sBaseMachDir, 1, true) then
|
|
package.path = package.path .. vLibDir[i] .. ';'
|
|
end
|
|
end
|
|
end
|
|
|
|
-- Funzione per dividere Path in Direttorio, NomeFile e Estensione
|
|
function EgtSplitPath( sPath)
|
|
local sDir, sFile = string.match(sPath, "(.-)([^\\/]*)$")
|
|
local sName, sExt
|
|
if sFile and string.find(sFile,'%.') then
|
|
sName, sExt = string.match(sFile,'(.*)([%.].-)$')
|
|
else
|
|
sName = sFile
|
|
sExt = ''
|
|
end
|
|
return sDir, sName, sExt
|
|
end
|
|
|
|
-- Funzione per cambiare estensione di una Path
|
|
function EgtChangePathExtension( sPath, sExt)
|
|
local sFileDir, sFileName, sFileExt = EgtSplitPath( sPath)
|
|
if string.sub( sExt, 1, 1) == '.' then
|
|
return sFileDir .. sFileName .. sExt
|
|
else
|
|
return sFileDir .. sFileName .. '.' .. sExt
|
|
end
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzioni di trim di stringhe di caratteri
|
|
function EgtTrimRight( sStr)
|
|
if not sStr then return nil end
|
|
return sStr:match( "(.-)%s*$")
|
|
end
|
|
function EgtTrimLeft( sStr)
|
|
if not sStr then return nil end
|
|
return sStr:match( "^%s*(.*)")
|
|
end
|
|
function EgtTrim( sStr)
|
|
if not sStr then return nil end
|
|
return sStr:match( "^%s*(.-)%s*$")
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per aggiungere/togliere coppie chiave/valore da una stringa di note
|
|
function EgtAdjustNotes( sNotes, sKey, Val)
|
|
local sNewNotes = ''
|
|
local vItem = EgtSplitString( sNotes, ';') or {}
|
|
for i = 1, #vItem do
|
|
local sItem = EgtTrim( vItem[i])
|
|
if sItem and #sItem > 0 and not sItem:find( sKey, 1, true) then
|
|
sNewNotes = sNewNotes .. sItem .. ';'
|
|
end
|
|
end
|
|
if Val and Val ~= '' then
|
|
sNewNotes = sNewNotes .. EgtSetVal( sKey, Val)
|
|
end
|
|
return sNewNotes
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per recuperare un valore data la chiave da una stringa di note
|
|
function EgtGetValInNotes( sNotes, sKey, sType)
|
|
local vItem = EgtSplitString( sNotes, ';') or {}
|
|
for i = 1, #vItem do
|
|
local sItem = EgtTrim( vItem[i])
|
|
if sItem and #sItem > 0 and sItem:find( sKey..'=', 1, true) then
|
|
return EgtGetVal( sItem, sKey, sType)
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per creare tabella da primo indice per numero indici consecutivi
|
|
function EgtTableFill( nStart, nCount)
|
|
if not nStart or nCount <= 0 then return nil end
|
|
local T = {}
|
|
for i = 0,nCount-1 do
|
|
table.insert( T, nStart+i)
|
|
end
|
|
return T
|
|
end
|
|
|
|
-- Funzione per aggiungere a tabella da primo indice per numero indici consecutivi
|
|
function EgtTableAdd( T, nStart, nCount)
|
|
if not nStart or nCount <= 0 then return T end
|
|
for i = 0,nCount-1 do
|
|
table.insert( T, nStart+i)
|
|
end
|
|
return T
|
|
end
|
|
|
|
-- Funzione per unire due tabelle
|
|
function EgtJoinTables( Ta, Tb)
|
|
for k, v in ipairs( Tb) do
|
|
table.insert( Ta, v)
|
|
end
|
|
return Ta
|
|
end
|
|
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Funzione per aggiornare interfaccia e consentire interruzione esecuzione
|
|
function EgtTestBreak( nProc, nPause)
|
|
local nRet = EgtProcessEvents( nProc, nPause)
|
|
if nRet == 1 then
|
|
error( "User aborted", 2)
|
|
end
|
|
end
|
|
|
|
----------------------------------------------------------------------------
|
|
-- Richiamo librerie componenti
|
|
require( 'EgtConst')
|
|
require( 'EgtVector3d')
|
|
require( 'EgtPoint3d')
|
|
require( 'EgtFrame3d')
|
|
require( 'EgtBBox3d')
|
|
require( 'EgtColor3d')
|
|
|
|
|
|
-- Ridefinizione funzioni per ritornare Vector3d
|
|
local o_EgtGetGridVersZ = EgtGetGridVersZ
|
|
EgtGetGridVersZ = function(...)
|
|
local vtV = o_EgtGetGridVersZ(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtSV = EgtSV
|
|
EgtSV = function(...)
|
|
local vtV = o_EgtSV(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtEV = EgtEV
|
|
EgtEV = function(...)
|
|
local vtV = o_EgtEV(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtMV = EgtMV
|
|
EgtMV = function(...)
|
|
local vtV = o_EgtMV(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtUV = EgtUV
|
|
EgtUV = function(...)
|
|
local vtV = o_EgtUV(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtET = EgtET
|
|
EgtET = function(...)
|
|
local vtV = o_EgtET(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtCurveExtrusion = EgtCurveExtrusion
|
|
EgtCurveExtrusion = function(...)
|
|
local vtV = o_EgtCurveExtrusion(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtArcNormVersor = EgtArcNormVersor
|
|
EgtArcNormVersor = function(...)
|
|
local vtV = o_EgtArcNormVersor(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtSurfFrNormVersor = EgtSurfFrNormVersor
|
|
EgtSurfFrNormVersor = function(...)
|
|
local vtV = o_EgtSurfFrNormVersor(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtSurfTmFacetNormVersor = EgtSurfTmFacetNormVersor
|
|
EgtSurfTmFacetNormVersor = function(...)
|
|
local vtV = o_EgtSurfTmFacetNormVersor(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtTextNormVersor = EgtTextNormVersor
|
|
EgtTextNormVersor = function(...)
|
|
local vtV = o_EgtTextNormVersor(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtGetCalcToolDirFromAngles = EgtGetCalcToolDirFromAngles
|
|
EgtGetCalcToolDirFromAngles = function(...)
|
|
local vtV = o_EgtGetCalcToolDirFromAngles(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
local o_EgtGetCalcAuxDirFromAngles = EgtGetCalcAuxDirFromAngles
|
|
EgtGetCalcAuxDirFromAngles = function(...)
|
|
local vtV = o_EgtGetCalcAuxDirFromAngles(...)
|
|
if vtV then return Vector3d( vtV) end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Vector3d e altri parametri
|
|
local o_EgtCurveIsFlat = EgtCurveIsFlat
|
|
EgtCurveIsFlat = function(...)
|
|
local bFlat, vtN, dDist = o_EgtCurveIsFlat(...)
|
|
if vtN then return bFlat, Vector3d( vtN), dDist end
|
|
end
|
|
local o_EgtCurveArea = EgtCurveArea
|
|
EgtCurveArea = function(...)
|
|
local vtN, dDist, dArea = o_EgtCurveArea(...)
|
|
if vtN then return Vector3d( vtN), dDist, dArea end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Point3d
|
|
local o_EgtSP = EgtSP
|
|
EgtSP = function(...)
|
|
local ptP = o_EgtSP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtEP = EgtEP
|
|
EgtEP = function(...)
|
|
local ptP = o_EgtEP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtMP = EgtMP
|
|
EgtMP = function(...)
|
|
local ptP = o_EgtMP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtCP = EgtCP
|
|
EgtCP = function(...)
|
|
local ptP = o_EgtCP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGP = EgtGP
|
|
EgtGP = function(...)
|
|
local ptP = o_EgtGP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtUP = EgtUP
|
|
EgtUP = function(...)
|
|
local ptP = o_EgtUP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtNP = EgtNP
|
|
EgtNP = function(...)
|
|
local ptP = o_EgtNP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtIP = EgtIP
|
|
EgtIP = function(...)
|
|
local ptP = o_EgtIP(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtCurveCompoCenter = EgtCurveCompoCenter
|
|
EgtCurveCompoCenter = function(...)
|
|
local ptP = o_EgtCurveCompoCenter(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGetTableRef = EgtGetTableRef
|
|
EgtGetTableRef = function(...)
|
|
local ptP = o_EgtGetTableRef(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGetCalcTipFromPositions = EgtGetCalcTipFromPositions
|
|
EgtGetCalcTipFromPositions = function(...)
|
|
local ptP = o_EgtGetCalcTipFromPositions(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGetRawPartCenter = EgtGetRawPartCenter
|
|
EgtGetRawPartCenter = function(...)
|
|
local ptP = o_EgtGetRawPartCenter(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGetMachiningStartPoint = EgtGetMachiningStartPoint
|
|
EgtGetMachiningStartPoint = function(...)
|
|
local ptP = o_EgtGetMachiningStartPoint(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
local o_EgtGetMachiningEndPoint = EgtGetMachiningEndPoint
|
|
EgtGetMachiningEndPoint = function(...)
|
|
local ptP = o_EgtGetMachiningEndPoint(...)
|
|
if ptP then return Point3d( ptP) end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Point3d e altri parametri
|
|
local o_EgtSurfTmFacetsContact = EgtSurfTmFacetsContact
|
|
EgtSurfTmFacetsContact = function(...)
|
|
local bAdj, ptP1, ptP2, dAng = o_EgtSurfTmFacetsContact(...)
|
|
if bAdj and ptP1 and ptP2 and dAng then
|
|
return bAdj, Point3d( ptP1), Point3d( ptP2), dAng
|
|
else
|
|
return bAdj
|
|
end
|
|
end
|
|
local o_EgtSurfTmFacetOppositeSide = EgtSurfTmFacetOppositeSide
|
|
EgtSurfTmFacetOppositeSide = function(...)
|
|
local ptP1, ptPm, ptP2, vtV1, vtV2, dL, dW = o_EgtSurfTmFacetOppositeSide(...)
|
|
if ptP1 and ptPm and ptP2 and vtV1 and vtV2 then
|
|
return Point3d( ptP1), Point3d( ptPm), Point3d( ptP2), Vector3d( vtV1), Vector3d( vtV2), dL, dW
|
|
end
|
|
end
|
|
local o_EgtPointCurveDist = EgtPointCurveDist
|
|
EgtPointCurveDist = function(...)
|
|
local dDist, ptNear, dU = o_EgtPointCurveDist(...)
|
|
if dDist then return dDist, Point3d( ptNear), dU end
|
|
end
|
|
local o_EgtGetLastSelInfo = EgtGetLastSelInfo
|
|
EgtGetLastSelInfo = function(...)
|
|
local nId, nSub, ptSel = o_EgtGetLastSelInfo(...)
|
|
if nId then return nId, nSub, Point3d( ptSel) end
|
|
end
|
|
local o_EgtGetPrevSelInfo = EgtGetPrevSelInfo
|
|
EgtGetPrevSelInfo = function(...)
|
|
local nId, nSub, ptSel = o_EgtGetPrevSelInfo(...)
|
|
if nId then return nId, nSub, Point3d( ptSel) end
|
|
end
|
|
local o_EgtSurfBezierGetPoint = EgtSurfBezierGetPoint
|
|
EgtSurfBezierGetPoint = function(...)
|
|
local ptP = o_EgtSurfBezierGetPoint(...)
|
|
if ptP then
|
|
return Point3d( ptP)
|
|
end
|
|
end
|
|
local o_EgtSurfBezierGetPointD1 = EgtSurfBezierGetPointD1
|
|
EgtSurfBezierGetPointD1 = function(...)
|
|
local ptP, vtDerU, vtDerV = o_EgtSurfBezierGetPointD1(...)
|
|
if ptP and vtDerU and vtDerV then
|
|
return Point3d( ptP), Vector3d( vtDerU), Vector3d( vtDerV)
|
|
end
|
|
end
|
|
local o_EgtSurfBezierGetPointNrmD1 = EgtSurfBezierGetPointNrmD1
|
|
EgtSurfBezierGetPointNrmD1 = function(...)
|
|
local ptP, vtN, vtDerU, vtDerV = o_EgtSurfBezierGetPointNrmD1(...)
|
|
if ptP and vtDerU and vtDerV then
|
|
return Point3d( ptP), Vector3d( vtN), Vector3d( vtDerU), Vector3d( vtDerV)
|
|
end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Point3d e Vector3d
|
|
local o_EgtSurfTmFacetNearestEndPoint = EgtSurfTmFacetNearestEndPoint
|
|
EgtSurfTmFacetNearestEndPoint = function(...)
|
|
local ptP, vtN = o_EgtSurfTmFacetNearestEndPoint(...)
|
|
if ptP and vtN then return Point3d( ptP), Vector3d( vtN) end
|
|
end
|
|
local o_EgtSurfTmFacetNearestMidPoint = EgtSurfTmFacetNearestMidPoint
|
|
EgtSurfTmFacetNearestMidPoint = function(...)
|
|
local ptP, vtN = o_EgtSurfTmFacetNearestMidPoint(...)
|
|
if ptP and vtN then return Point3d( ptP), Vector3d( vtN) end
|
|
end
|
|
local o_EgtSurfTmFacetCenter = EgtSurfTmFacetCenter
|
|
EgtSurfTmFacetCenter = function(...)
|
|
local ptP, vtN = o_EgtSurfTmFacetCenter(...)
|
|
if ptP and vtN then return Point3d( ptP), Vector3d( vtN) end
|
|
end
|
|
local o_EgtCurveIsACircle = EgtCurveIsACircle
|
|
EgtCurveIsACircle = function(...)
|
|
local bCirc, ptC, vtN, dRad, bCCW = o_EgtCurveIsACircle(...)
|
|
if bCirc then return bCirc, Point3d( ptC), Vector3d( vtN), dRad, bCCW end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Frame3d
|
|
local o_EgtGetGridFrame = EgtGetGridFrame
|
|
EgtGetGridFrame = function()
|
|
local frRef = o_EgtGetGridFrame()
|
|
if frRef then return Frame3d( frRef) end
|
|
end
|
|
local o_EgtGetGlobFrame = EgtGetGlobFrame
|
|
EgtGetGlobFrame = function(...)
|
|
local frRef = o_EgtGetGlobFrame(...)
|
|
if frRef then return Frame3d( frRef) end
|
|
end
|
|
local o_EgtGetGroupGlobFrame = EgtGetGroupGlobFrame
|
|
EgtGetGroupGlobFrame = function(...)
|
|
local frRef = o_EgtGetGroupGlobFrame(...)
|
|
if frRef then return Frame3d( frRef) end
|
|
end
|
|
local o_EgtFR = EgtFR
|
|
EgtFR = function(...)
|
|
local frRef = o_EgtFR(...)
|
|
if frRef then return Frame3d( frRef) end
|
|
end
|
|
local o_EgtGetTextureFrame = EgtGetTextureFrame
|
|
EgtGetTextureFrame = function(...)
|
|
local frRef = o_EgtGetTextureFrame(...)
|
|
if frRef then return Frame3d( frRef) end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Frame3d e altri parametri
|
|
local o_EgtCurveMinAreaRectangleXY = EgtCurveMinAreaRectangleXY
|
|
EgtCurveMinAreaRectangleXY = function(...)
|
|
local frRect, dDimX, dDimY = o_EgtCurveMinAreaRectangleXY(...)
|
|
if frRect then return Frame3d( frRect), dDimX, dDimY end
|
|
end
|
|
local o_EgtSurfTmFacetMinAreaRectangle = EgtSurfTmFacetMinAreaRectangle
|
|
EgtSurfTmFacetMinAreaRectangle = function(...)
|
|
local frRect, dDimX, dDimY = o_EgtSurfTmFacetMinAreaRectangle(...)
|
|
if frRect then return Frame3d( frRect), dDimX, dDimY end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare BBox3d
|
|
local o_EgtGetBBox = EgtGetBBox
|
|
EgtGetBBox = function(...)
|
|
local b3Box = o_EgtGetBBox(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtGetBBoxGlob = EgtGetBBoxGlob
|
|
EgtGetBBoxGlob = function(...)
|
|
local b3Box = o_EgtGetBBoxGlob(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtGetBBoxRef = EgtGetBBoxRef
|
|
EgtGetBBoxRef = function(...)
|
|
local b3Box = o_EgtGetBBoxRef(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtGetTableArea = EgtGetTableArea
|
|
EgtGetTableArea = function(...)
|
|
local b3Box = o_EgtGetTableArea(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtGetRawPartBBox = EgtGetRawPartBBox
|
|
EgtGetRawPartBBox = function(...)
|
|
local b3Box = o_EgtGetRawPartBBox(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtSurfTmGetFacetBBox = EgtSurfTmGetFacetBBox
|
|
EgtSurfTmGetFacetBBox = function(...)
|
|
local b3Box = o_EgtSurfTmGetFacetBBox(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtSurfTmGetFacetBBoxGlob = EgtSurfTmGetFacetBBoxGlob
|
|
EgtSurfTmGetFacetBBoxGlob = function(...)
|
|
local b3Box = o_EgtSurfTmGetFacetBBoxGlob(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtSurfTmGetFacetBBoxRef = EgtSurfTmGetFacetBBoxRef
|
|
EgtSurfTmGetFacetBBoxRef = function(...)
|
|
local b3Box = o_EgtSurfTmGetFacetBBoxRef(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtVolZmapGetPartBBox = EgtVolZmapGetPartBBox
|
|
EgtVolZmapGetPartBBox = function(...)
|
|
local b3Box = o_EgtVolZmapGetPartBBox(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
local o_EgtVolZmapGetPartBBoxGlob = EgtVolZmapGetPartBBoxGlob
|
|
EgtVolZmapGetPartBBoxGlob = function(...)
|
|
local b3Box = o_EgtVolZmapGetPartBBoxGlob(...)
|
|
if b3Box then return BBox3d( b3Box) end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per ritornare Color3d
|
|
local o_EgtStdColor = EgtStdColor
|
|
EgtStdColor = function(...)
|
|
local c3Col = o_EgtStdColor(...)
|
|
if c3Col then return Color3d( c3Col) end
|
|
end
|
|
local o_EgtGetColor = EgtGetColor
|
|
EgtGetColor = function(...)
|
|
local c3Col = o_EgtGetColor(...)
|
|
if c3Col then return Color3d( c3Col) end
|
|
end
|
|
local o_EgtGetCalcColor = EgtGetCalcColor
|
|
EgtGetCalcColor = function(...)
|
|
local c3Col = o_EgtGetCalcColor(...)
|
|
if c3Col then return Color3d( c3Col) end
|
|
end
|
|
local o_EgtGetBackground = EgtGetBackground
|
|
EgtGetBackground = function(...)
|
|
local c3Top, c3Bot = o_EgtGetBackground(...)
|
|
if c3Top and c3Bot then return Color3d( c3Top), Color3d( c3Bot) end
|
|
end
|
|
|
|
-- Ridefinizione funzioni per tornare diversi tipi di oggetti
|
|
local o_EgtGetInfo = EgtGetInfo
|
|
EgtGetInfo = function( Id, Key, sType)
|
|
local Val = o_EgtGetInfo( Id, Key, sType)
|
|
if sType == 'v' or sType == 'V' then
|
|
if Val then return Vector3d( Val) end
|
|
elseif sType == 'p' or sType == 'P' then
|
|
if Val then return Point3d( Val) end
|
|
elseif sType == 'x' or sType == 'X' then
|
|
if Val then return BBox3d( Val) end
|
|
elseif sType == 'f' or sType == 'F' then
|
|
if Val then return Frame3d( Val) end
|
|
else
|
|
return Val
|
|
end
|
|
end
|
|
|
|
|
|
return EgtBase
|