Merge remote-tracking branch 'origin/feature/GetMainFaces' into feature/GetForcedStrategy
This commit is contained in:
+60
-7
@@ -14,6 +14,8 @@ EgtOutLog( ' BeamLib started', 1)
|
||||
-- Dati
|
||||
local BD = require( 'BeamData')
|
||||
|
||||
--TODO refactoring di queste funzioni
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
function BeamLib.AddPartStartFace( PartId, b3Solid)
|
||||
-- recupero gruppo per geometria aggiuntiva
|
||||
@@ -23,6 +25,7 @@ function BeamLib.AddPartStartFace( PartId, b3Solid)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
-- aggiungo nuovo taglio iniziale
|
||||
local nStmId = EgtSurfTmPlaneInBBox( AddGrpId, b3Solid:getMax(), X_AX(), b3Solid, GDB_RT.GLOB)
|
||||
if not nStmId then
|
||||
@@ -47,6 +50,7 @@ function BeamLib.AddPartStartFace( PartId, b3Solid)
|
||||
end
|
||||
nProcId = EgtGetNext( nProcId)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -59,6 +63,7 @@ function BeamLib.AddPartEndFace( PartId, b3Solid)
|
||||
EgtOutLog( sErr)
|
||||
return false, sErr
|
||||
end
|
||||
|
||||
-- aggiungo nuovo taglio finale
|
||||
local nStmId = EgtSurfTmPlaneInBBox( AddGrpId, b3Solid:getMin(), -X_AX(), b3Solid, GDB_RT.GLOB)
|
||||
if not nStmId then
|
||||
@@ -83,6 +88,7 @@ function BeamLib.AddPartEndFace( PartId, b3Solid)
|
||||
end
|
||||
nProcId = EgtGetNext( nProcId)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -105,7 +111,10 @@ end
|
||||
function BeamLib.CreateOrEmptyAddGroup( PartId)
|
||||
-- recupero i dati del gruppo aggiuntivo
|
||||
local AddGrpId, sMchGrp = BeamLib.GetAddGroup( PartId)
|
||||
if not sMchGrp then return false end
|
||||
if not sMchGrp then
|
||||
return false
|
||||
end
|
||||
|
||||
-- se esiste, aggiorno riferimento al gruppo di lavoro e lo svuoto
|
||||
if AddGrpId then
|
||||
EgtSetInfo( AddGrpId, GDB_SI.MGRPONLY, EgtGetCurrMachGroup())
|
||||
@@ -113,11 +122,14 @@ function BeamLib.CreateOrEmptyAddGroup( PartId)
|
||||
end
|
||||
-- altrimenti lo creo
|
||||
AddGrpId = EgtGroup( PartId or GDB_ID.NULL)
|
||||
if not AddGrpId then return false end
|
||||
if not AddGrpId then
|
||||
return false
|
||||
end
|
||||
-- assegno nome, flag di layer per gruppo di lavoro e colore
|
||||
EgtSetName( AddGrpId, sMchGrp)
|
||||
EgtSetInfo( AddGrpId, GDB_SI.MGRPONLY, EgtGetCurrMachGroup())
|
||||
EgtSetColor( AddGrpId, Color3d( 80, 160, 160, 50))
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -125,9 +137,13 @@ end
|
||||
function BeamLib.GetAddGroup( PartId)
|
||||
-- recupero il nome del gruppo di lavoro corrente
|
||||
local sMchGrp = EgtGetMachGroupName( EgtGetCurrMachGroup() or GDB_ID.NULL)
|
||||
if not sMchGrp then return nil, nil end
|
||||
if not sMchGrp then
|
||||
return nil, nil
|
||||
end
|
||||
|
||||
-- cerco il gruppo aggiuntivo omonimo nel pezzo e se esiste lo restituisco
|
||||
local AddGrpId = EgtGetFirstNameInGroup( PartId or GDB_ID.NULL, sMchGrp)
|
||||
|
||||
-- restituisco Id e Nome
|
||||
return AddGrpId, sMchGrp
|
||||
end
|
||||
@@ -164,15 +180,18 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
-- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce
|
||||
function BeamLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId)
|
||||
function BeamLib.Is3EdgesApprox( Proc, idFace, nAddGrpId)
|
||||
nAddGrpId = nAddGrpId or BeamLib.GetAddGroup( Proc.PartId)
|
||||
if not nAddGrpId then
|
||||
local nEdges = #(EgtSurfTmFacetAdjacencies( Proc.Id, nFacet)[1])
|
||||
local nEdges = #(EgtSurfTmFacetAdjacencies( Proc.Id, idFace)[1])
|
||||
return ( nEdges == 3)
|
||||
end
|
||||
local bResult = false
|
||||
local nContourId, nContourCnt = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId)
|
||||
if not nContourId then return false end
|
||||
|
||||
local nContourId, nContourCnt = EgtExtractSurfTmFacetLoops( Proc.Id, idFace, nAddGrpId)
|
||||
if not nContourId then
|
||||
return false
|
||||
end
|
||||
EgtMergeCurvesInCurveCompo( nContourId)
|
||||
-- recupero il numero effettivo di lati
|
||||
local _, nEntityCount = EgtCurveDomain( nContourId)
|
||||
@@ -189,8 +208,42 @@ function BeamLib.Is3EdgesApprox( Proc, nFacet, nAddGrpId)
|
||||
if nEdges == 3 then bResult = true end
|
||||
-- cancello tutti i contorni appena creati
|
||||
EgtErase( EgtTableFill( nContourId, nContourCnt))
|
||||
|
||||
return bResult
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
--- ritorna il riferimento di tipo OCS della faccia *idFace* della trimesh *nSurfId* e le dimensioni orizzontale e verticale, eventualmente limitate dal grezzo *b3Raw*
|
||||
function BeamLib.GetFaceHvRefDim( nSurfId, idFace, b3Raw)
|
||||
-- recupero centro e normale della faccia
|
||||
local ptC, vtN = EgtSurfTmFacetCenter( nSurfId, idFace, GDB_ID.ROOT)
|
||||
if not ptC or not vtN then
|
||||
return
|
||||
end
|
||||
-- riferimento tipo OCS della faccia (X orizz, Y max pendenza, Z normale)
|
||||
local frHV = Frame3d( ptC, vtN)
|
||||
if frHV:getVersY():getZ() < 0 then
|
||||
frHV:rotate( ptC, vtN, 180)
|
||||
end
|
||||
-- determino l'ingombro in questo riferimento
|
||||
local b3HV = EgtSurfTmGetFacetBBoxRef( nSurfId, idFace, GDB_BB.STANDARD, frHV)
|
||||
local dDimH = b3HV:getDimX()
|
||||
local dDimV = b3HV:getDimY()
|
||||
-- se definito grezzo (o solido), applico eventuali limiti
|
||||
if b3Raw then
|
||||
local dCoeffY = abs( frHV:getVersX():getY())
|
||||
if dCoeffY > GEO.EPS_SMALL then
|
||||
dDimH = min( dDimH, b3Raw:getDimY() / dCoeffY)
|
||||
end
|
||||
local dCoeffZ = abs( frHV:getVersY():getZ())
|
||||
if dCoeffZ > GEO.EPS_SMALL then
|
||||
dDimV = min( dDimV, b3Raw:getDimZ() / dCoeffZ)
|
||||
end
|
||||
end
|
||||
|
||||
-- restituisco i valori calcolati
|
||||
return frHV, dDimH, dDimV
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
return BeamLib
|
||||
|
||||
Reference in New Issue
Block a user