Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e015136592 | |||
| 72d1b61c6a | |||
| 02fe05d5e1 | |||
| 3c839716f8 | |||
| 2fc63b0d25 | |||
| 9c42a70c6a | |||
| 922c5510c0 | |||
| 56ff8468f0 | |||
| 63efafde60 | |||
| 49c8361bc5 | |||
| a7c7bd63ed | |||
| 4da4b8cf4d |
@@ -16,3 +16,4 @@ REM Compilazione 32 e 64 bit
|
||||
\EgtProg\Dll32\luac54 -o bin\CalcSolids.lua CalcSolids.lua
|
||||
\EgtProg\Dll32\luac54 -o bin\GcodeGenerate.lua GcodeGenerate.lua
|
||||
\EgtProg\Dll32\luac54 -o bin\Slicing.lua Slicing.lua
|
||||
\EgtProg\Dll32\luac54 -o bin\Version.lua Version.lua
|
||||
|
||||
@@ -109,6 +109,7 @@ KEY_START_RIB = "StartRib"
|
||||
KEY_ORIGINAL_RIB = "OriginalRib"
|
||||
KEY_LOOP_RIB = "LoopRib"
|
||||
KEY_RIBS_USER_LINK = "RibWithUserLink"
|
||||
KEY_RIBS_USER_LINK_SAME_SIDE = "RibUserLinkOnSameSide"
|
||||
KEY_RIBS_USER_LINK_CCW = "RibUserLinkCCW"
|
||||
KEY_RIBS_USER_LINK_ORDER = "RibUserLinkOrder"
|
||||
KEY_RIBS_USER_LINK_TOT = "RibsUserLinkParts"
|
||||
@@ -152,6 +153,7 @@ KEY_INVERTED_CRV = "InvertedCrv"
|
||||
KEY_CLOSED_CRV = "ClosedCrv"
|
||||
KEY_ASSOCIATED_SURF = "AssociatedSurf"
|
||||
KEY_ASSOCIATED_CRVS = "AssociatedCrvs"
|
||||
KEY_ORIGINAL_SURF = "OriginalSurf"
|
||||
KEY_HAS_SOLIDS = "Solids"
|
||||
KEY_BOX_MIN_Z = "PartBoxMinZ"
|
||||
KEY_START_POINT = "StartPoint"
|
||||
@@ -284,6 +286,7 @@ SLICE_ADV_TYPE = {
|
||||
---------------------------------------------------------------------
|
||||
RIBS_GRP = "Ribs"
|
||||
RIBS_CRV = "Rib"
|
||||
RIBS_LOOP_GRP = "RibsLoops"
|
||||
|
||||
SHELL_NBR_GRP = "ShellNbrRegions"
|
||||
SHELL_NBR_CRV = "ShellNbrRegion"
|
||||
|
||||
+802
-220
File diff suppressed because it is too large
Load Diff
+77
-30
@@ -15,6 +15,13 @@ local AMD = require( 'AddManData')
|
||||
---------------------------------------------------------------------
|
||||
local s_nPartId
|
||||
|
||||
-- costanti
|
||||
local TOLER = 0.05
|
||||
local MID_TOLER = 0.1
|
||||
local BIG_TOLER = 2.0
|
||||
local MIN_LEN = 20.0
|
||||
local MIN_AREA = 25.0
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function ComputeZSlices( dSliceStep, dZmin, dDeltaZ, dZmax)
|
||||
|
||||
@@ -70,6 +77,49 @@ local function ComputeMaxH( vIds, frSlicing, HMax, dSliceStep)
|
||||
return GEO.INFINITO
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ReadParam( nId, sKey, sType, defVal, table)
|
||||
-- verifico se info nell'oggetto specifico
|
||||
local info = EgtGetInfo( nId, sKey, sType)
|
||||
-- altrimenti recupero info dai parametri generali
|
||||
if info == nil then info = EgtGetInfo( s_nPartId, sKey, sType) end
|
||||
-- o assegno valore di default
|
||||
if info == nil then info = defVal end
|
||||
|
||||
-- se presente, inserisco l'info nella tabella
|
||||
if table then table[sKey] = info end
|
||||
|
||||
return info
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ExtractRibsLoops( nRibsGrp, nStmId)
|
||||
|
||||
local nLoopGrp = EgtGroup( s_nPartId)
|
||||
EgtSetName( nLoopGrp, RIBS_LOOP_GRP)
|
||||
EgtSetStatus( nLoopGrp, GDB_ST.OFF)
|
||||
|
||||
-- recupero tutti i setti
|
||||
local vIds = EgtGetAllInGroup( nRibsGrp)
|
||||
for i = 1, #vIds do
|
||||
-- se trimesh
|
||||
if EgtGetType( vIds[i]) == GDB_TY.SRF_MESH then
|
||||
-- trim con il solido
|
||||
local nCopy = EgtCopyGlob( vIds[i], nLoopGrp)
|
||||
local nType = ReadParam( vIds[i], KEY_RIBS_TYPE, 'i', RIB_TYPE.INTERNAL)
|
||||
EgtSurfTmCut( nCopy, nStmId, nType ~= RIB_TYPE.EXTERNAL, false)
|
||||
-- estraggo i contorni
|
||||
local nCrv, nCnt = EgtExtractSurfTmLoops( nCopy, nLoopGrp)
|
||||
if nCrv then
|
||||
-- assegno nome che permetta di ricondurli alla superficie da cui derivano
|
||||
for nId = nCrv, nCrv + nCnt - 1 do
|
||||
EgtSetName( nId, SURF_LOOP .. tostring( vIds[i]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AdjustAuxSolids( nSolidsLay)
|
||||
|
||||
@@ -105,21 +155,6 @@ local function AdjustAuxSolids( nSolidsLay)
|
||||
EgtErase( nGrpTmp)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function ReadParam( nId, sKey, sType, defVal, table)
|
||||
-- verifico se info nell'oggetto specifico
|
||||
local info = EgtGetInfo( nId, sKey, sType)
|
||||
-- altrimenti recupero info dai parametri generali
|
||||
if info == nil then info = EgtGetInfo( s_nPartId, sKey, sType) end
|
||||
-- o assegno valore di default
|
||||
if info == nil then info = defVal end
|
||||
|
||||
-- se presente, inserisco l'info nella tabella
|
||||
if table then table[sKey] = info end
|
||||
|
||||
return info
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function GetRibParams( nId)
|
||||
|
||||
@@ -171,7 +206,7 @@ local function GetAuxSolidsParams( nId)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, nStmId)
|
||||
local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, vErr, nStmId)
|
||||
|
||||
-- recupero gli oggeti di cui fare slicing
|
||||
local vIds = EgtGetAllInGroup( nLay)
|
||||
@@ -203,7 +238,6 @@ local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, nSt
|
||||
if vParams[KEY_SHELL_NBR_DIFF] == 0 then bToBeDone = false end
|
||||
elseif nType == TYPE.AUX_SOLID then
|
||||
vParams = GetAuxSolidsParams( vIds[i])
|
||||
if vParams[KEY_AUX_SOLIDS_INFILL] == INFILL_TYPE.NONE then bToBeDone = false end
|
||||
end
|
||||
table.insert( tabParams, vParams)
|
||||
table.insert( vToBeDone, bToBeDone)
|
||||
@@ -234,7 +268,8 @@ local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, nSt
|
||||
-- recupero quota per slicing
|
||||
local dZ = EgtGetInfo( nLayId, KEY_SLICE_REAL_Z, 'd')
|
||||
local dDeltaZ = EgtGetInfo( nLayId, KEY_SLICE_DELTAZ, 'd')
|
||||
-- creo gruppo per le costolature
|
||||
local nLayCnt = EgtGetInfo( nLayId, KEY_SLICE_NBR, 'i')
|
||||
-- creo gruppo per gli oggetti
|
||||
local nGrp = EgtGroup( nLayId)
|
||||
EgtSetName( nGrp, sNameGrp)
|
||||
EgtSetStatus( nGrp, GDB_ST.OFF)
|
||||
@@ -257,6 +292,7 @@ local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, nSt
|
||||
end
|
||||
|
||||
if nSrfCnt > 0 or bOpen then
|
||||
EgtOutLog( 'Warning : recalc at layer '.. EgtNumToString( nLayCnt) .. ' (object)')
|
||||
-- elimino vecchio risultato
|
||||
for j = nNewId, nNewId + nPntCnt + nCrvCnt + nSrfCnt - 1 do
|
||||
EgtErase( j)
|
||||
@@ -266,18 +302,34 @@ local function SlicingExtraObjects( vtSlicing, nLay, nType, sNameGrp, sName, nSt
|
||||
end
|
||||
|
||||
if nNewId then
|
||||
|
||||
-- rimuovo punti
|
||||
for nId = nNewId, nNewId + nPntCnt -1 do
|
||||
EgtErase( nId)
|
||||
end
|
||||
|
||||
-- concateno le curve
|
||||
local vChain = {}
|
||||
for nId = nNewId + nPntCnt, nNewId + nPntCnt + nCrvCnt - 1 do
|
||||
table.insert( vChain, nId)
|
||||
end
|
||||
local nChainId, nCnt = EgtCurveCompoByChain( nGrp, vChain, ORIG(), true, GDB_RT.LOC, BIG_TOLER)
|
||||
-- rinomino le curve, correggo di DeltaZ e assegno parametri
|
||||
for nId = nNewId + nPntCnt, nNewId + nPntCnt + nCrvCnt - 1 do
|
||||
EgtSetName( nId, sName .. tostring( i))
|
||||
EgtMove( nId, - ( dDeltaZ + dCorr) * vtSlicing)
|
||||
EgtSetInfo( nId, KEY_ORIGINAL_SURF, vIds[i])
|
||||
for sKey, sVal in pairs( tabParams[i]) do
|
||||
EgtSetInfo( nId, sKey, sVal)
|
||||
end
|
||||
|
||||
-- se ho ancora curve aperte, segnalo errore
|
||||
if nType ~= TYPE.RIB and not EgtCurveIsClosed( nId) then
|
||||
EgtOutLog( 'Error : hole in object (layer '.. EgtNumToString( nLayCnt) ..') - CalcSlices')
|
||||
table.insert( vErr, nLayCnt)
|
||||
end
|
||||
end
|
||||
|
||||
-- rimuovo superfici
|
||||
for nId = nNewId + nPntCnt + nCrvCnt, nNewId + nPntCnt + nCrvCnt + nSrfCnt - 1 do
|
||||
EgtErase( nId)
|
||||
@@ -337,7 +389,7 @@ local function SlicingNoSolid( nRibsLay, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
if EgtProcessEvents( EgtIf( PRINT, 100, 0) + 20, 0) == 1 then return false end
|
||||
|
||||
-- slicing dei setti
|
||||
SlicingExtraObjects( vtSlicing, nRibsLay, TYPE.RIB, RIBS_GRP, RIBS_CRV)
|
||||
SlicingExtraObjects( vtSlicing, nRibsLay, TYPE.RIB, RIBS_GRP, RIBS_CRV, vErr)
|
||||
if EgtProcessEvents( EgtIf( PRINT, 100, 0) + 100, 0) == 1 then return false end
|
||||
|
||||
return true
|
||||
@@ -345,13 +397,6 @@ end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicing, vErr)
|
||||
|
||||
-- costanti
|
||||
local TOLER = 0.05
|
||||
local MID_TOLER = 0.1
|
||||
local BIG_TOLER = 2.0
|
||||
local MIN_LEN = 20.0
|
||||
local MIN_AREA = 25.0
|
||||
|
||||
local vtSlicing = frSlicing:getVersZ()
|
||||
|
||||
@@ -395,7 +440,7 @@ local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
dDeltaZ = dDeltaZ + EgtIf( vtRecalc and vtRecalc:getZ() > 0, -0.01, 0.01)
|
||||
-- eseguo il ricalcolo solo a quella quota
|
||||
EgtPlaneSurfTmInters( ORIG() + ( dPosZ + dDeltaZ) * vtSlicing, vtSlicing, nStmId, nLayId, GDB_RT.GLOB, TOLER)
|
||||
EgtOutLog( 'Warning : Recalc at Lay'.. EgtNumToString( nLayCnt))
|
||||
EgtOutLog( 'Warning : recalc at layer '.. EgtNumToString( nLayCnt))
|
||||
end
|
||||
EgtSetInfo( nLayId, KEY_SLICE_DELTAZ, dDeltaZ)
|
||||
|
||||
@@ -586,6 +631,7 @@ local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
|
||||
-- se vero errore lo segnalo
|
||||
if bErr then
|
||||
EgtOutLog( 'Error : hole in solid (layer '.. EgtNumToString( nLayCnt) ..') - CalcSlices')
|
||||
table.insert( vErr, nLayCnt)
|
||||
-- cambio nome al layer
|
||||
EgtSetName( nLayId, '__' .. SLICE_LAYER .. EgtNumToString( nLayCnt))
|
||||
@@ -617,14 +663,15 @@ local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
-- costolature
|
||||
local nRibsLay = EgtGetFirstNameInGroup( s_nPartId, LAY_RIBS)
|
||||
if nRibsLay then
|
||||
SlicingExtraObjects( vtSlicing, nRibsLay, TYPE.RIB, RIBS_GRP, RIBS_CRV, nStmId)
|
||||
ExtractRibsLoops( nRibsLay, nStmId)
|
||||
SlicingExtraObjects( vtSlicing, nRibsLay, TYPE.RIB, RIBS_GRP, RIBS_CRV, vErr, nStmId)
|
||||
end
|
||||
if EgtProcessEvents( EgtIf( PRINT, 100, 0) + ( #vZSlices + 1) / ( #vZSlices + 3) * 100, 0) == 1 then return false end
|
||||
|
||||
-- solidi per regioni con diverso numero di passate
|
||||
local nShellNbrLay = EgtGetFirstNameInGroup( s_nPartId, LAY_SHELL_NBR)
|
||||
if nShellNbrLay then
|
||||
SlicingExtraObjects( vtSlicing, nShellNbrLay, TYPE.EXTRA_SHELL, SHELL_NBR_GRP, SHELL_NBR_CRV, nStmId)
|
||||
SlicingExtraObjects( vtSlicing, nShellNbrLay, TYPE.EXTRA_SHELL, SHELL_NBR_GRP, SHELL_NBR_CRV, vErr, nStmId)
|
||||
end
|
||||
if EgtProcessEvents( EgtIf( PRINT, 100, 0) + ( #vZSlices + 2) / ( #vZSlices + 3) * 100, 0) == 1 then return false end
|
||||
|
||||
@@ -632,7 +679,7 @@ local function SlicingWithSolid( nStmId, vZSlices, dDeltaZStart, dZmin, frSlicin
|
||||
local nAuxSolidsLay = EgtGetFirstNameInGroup( s_nPartId, LAY_AUX_SOLIDS)
|
||||
if nAuxSolidsLay then
|
||||
AdjustAuxSolids( nAuxSolidsLay)
|
||||
SlicingExtraObjects( vtSlicing, nAuxSolidsLay, TYPE.AUX_SOLID, AUX_SOLIDS_GRP, AUX_SOLIDS_CRV, nStmId)
|
||||
SlicingExtraObjects( vtSlicing, nAuxSolidsLay, TYPE.AUX_SOLID, AUX_SOLIDS_GRP, AUX_SOLIDS_CRV, vErr, nStmId)
|
||||
end
|
||||
if EgtProcessEvents( EgtIf( PRINT, 100, 0) + ( #vZSlices + 3) / ( #vZSlices + 3) * 100, 0) == 1 then return false end
|
||||
end
|
||||
|
||||
+286
-276
@@ -349,18 +349,25 @@ local function AddRetraction( nCrvId, vtSlicing, dCoastingLen, dWipeLen, dWipeDi
|
||||
nCopyId = nil
|
||||
EgtTrimCurveEndAtLen( nWipeId, dWipeLen)
|
||||
else
|
||||
-- se extra shell, infill a zigzag, spiral vase o rib che non termina sulla parete
|
||||
local vtDir = EgtEV( nCoastingId or nCrvId, GDB_ID.ROOT)
|
||||
local dAng = dWipeDir + s_nDefaultWipeAng
|
||||
-- verifico se necessario cambiare il segno all'angolo
|
||||
local bChangeSign = false
|
||||
-- riempimento
|
||||
if nType == TYPE.INFILL or nType == TYPE.AUX_SOLID then
|
||||
local vtS = EgtGetInfo( nCrvId, KEY_ZIG_ZAG_DIR, 'v')
|
||||
local bSameDir = AreSameVectorApprox( vtS, vtDir)
|
||||
bChangeSign = ( bInverted == bSameDir)
|
||||
else
|
||||
-- rib
|
||||
elseif nType == TYPE.RIB then
|
||||
local bInvertStrandOrder = EgtGetInfo( nCrvId, KEY_RIBS_INVERT_STRAND_ORDER, 'b') or false
|
||||
local bInvertDir = EgtGetInfo( nCrvId, KEY_RIBS_INVERT_DIR, 'b') or false
|
||||
bChangeSign = ( bInvertDir ~= bInvertStrandOrder)
|
||||
-- extra shell
|
||||
elseif nType == TYPE.EXTRA_SHELL or nType == TYPE.EXTRA_OUTER_SHELL then
|
||||
bChangeSign = bInverted
|
||||
end
|
||||
|
||||
vtDir:rotate( vtSlicing, EgtIf( bChangeSign, - dAng, dAng))
|
||||
local ptS = EgtEP( nCoastingId or nCrvId, GDB_ID.ROOT)
|
||||
local ptE = FindWipeEndPoint( ptS, vtDir, dWipeLen, vtSlicing)
|
||||
@@ -561,318 +568,329 @@ end
|
||||
-------------------------------------------------------------------
|
||||
--------------------------- RIBS -----------------------------------
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp)
|
||||
local function VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp, bCheckLinked)
|
||||
|
||||
local dLen = EgtCurveLength( nLinkId)
|
||||
if dLen < dStrand + GEO.EPS_SMALL then
|
||||
return true
|
||||
end
|
||||
|
||||
local nGrp = EgtGetParent( nCurr)
|
||||
|
||||
-- verifico se il link interseca le due curve nell'altro estremo
|
||||
local ptS = EgtSP( nCurr)
|
||||
local ptE = EgtEP( nNext)
|
||||
local dParS = EgtCurveParamAtPoint( nLinkId, ptS)
|
||||
local dParE = EgtCurveParamAtPoint( nLinkId, ptE)
|
||||
if nCurr ~= nNext and ( dParS or dParE) then
|
||||
-- regione occupata dal link
|
||||
local nLinkLoc = EgtCopyGlob( nLinkId, nGrpTmp)
|
||||
local nOverlap = EgtGetInfo( nCurr, KEY_RIBS_OVERLAP, 'i')
|
||||
local nSrfLink = EgtSurfFrFatCurve( nGrpTmp, nLinkId, dStrand * ( 1 - nOverlap / 100) - 100 * GEO.EPS_SMALL, false)
|
||||
if not nSrfLink then
|
||||
return false
|
||||
end
|
||||
|
||||
-- verifico se si trova nella regione ammissibile
|
||||
local nSurfId = EgtGetInfo( nCurr, KEY_ASSOCIATED_SURF, 'i')
|
||||
local nRes = EgtCurveWithRegionClassify( nLinkId, nSurfId)
|
||||
local nType1 = EgtGetInfo( nCurr, KEY_RIBS_TYPE, 'i')
|
||||
local nType2 = EgtGetInfo( nNext, KEY_RIBS_TYPE, 'i')
|
||||
if ( nType1 == RIB_TYPE.INTERNAL or nType1 == RIB_TYPE.SUPPORT) and ( nType2 == RIB_TYPE.INTERNAL or nType2 == RIB_TYPE.SUPPORT) then
|
||||
if nRes == GDB_CRC.OUT or nRes == GDB_CRC.INTERS then
|
||||
return false
|
||||
end
|
||||
elseif nType1 == RIB_TYPE.EXTERNAL and nType2 == RIB_TYPE.EXTERNAL then
|
||||
if nRes == GDB_CRC.IN or nRes == GDB_CRC.INTERS then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se il link interseca una delle altre costolature
|
||||
local vRibsIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. '*')
|
||||
local nLinkSrf = EgtSurfFrFatCurve( nGrpTmp, nLinkId, 0.5 * dStrand, false) or GDB_ID.NULL
|
||||
-- verifico se interseca altri setti
|
||||
local vRibsIds = EgtGetNameInGroup( EgtGetParent( nCurr), RIBS_CRV .. '*')
|
||||
for i = 1, #vRibsIds do
|
||||
if vRibsIds[i] ~= nCurr and vRibsIds[i] ~= nNext then
|
||||
local nRes = EgtCurveWithRegionClassify( vRibsIds[i], nLinkSrf)
|
||||
if nRes == GDB_CRC.INTERS then
|
||||
local nRibsLoc = EgtCopyGlob( vRibsIds[i], nGrpTmp)
|
||||
local nRes = EgtCurveWithRegionClassify( vRibsIds[i], nSrfLink)
|
||||
if nRes ~= GDB_CRC.OUT then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- eventuale verifica con setti coinvolti dal link ( da fare solo se collegamento fra passate di setti diversi)
|
||||
if bCheckLinked and dLen > 3 * dStrand then
|
||||
-- regione occupata dai setti
|
||||
local nSrfRibs = EgtSurfFrFatCurve( nGrpTmp, nCurr, dStrand, false) or GDB_ID.NULL
|
||||
local nSrfRibs2 = EgtSurfFrFatCurve( nGrpTmp, nNext, dStrand, false) or GDB_ID.NULL
|
||||
EgtSurfFrAdd( nSrfRibs, nSrfRibs2)
|
||||
-- verifico che i tratti fuori abbiano lunghezza maggiore di quelli dentro
|
||||
local nRes, nCnt = EgtTrimCurveWithRegion( nLinkLoc, nSrfRibs, false, false)
|
||||
if nCnt == 0 then return false end
|
||||
local dResLen = EgtCurveLength( nRes)
|
||||
if dResLen < ( dLen - dResLen) - GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
|
||||
-- verifico non passi per estremo errato
|
||||
local dParTest1 = EgtCurveParamAtPoint( nLinkId, EgtSP( nCurr, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
local dParTest2 = EgtCurveParamAtPoint( nLinkId, EgtEP( nNext, GDB_ID.ROOT), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParTest1 or dParTest2 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico se si trova nella regione ammissibile ( per caso ForcedLink)
|
||||
local nSurfId = EgtGetInfo( nCurr, KEY_ASSOCIATED_SURF, 'i')
|
||||
if nSurfId then
|
||||
local nSrfLoc = EgtCopyGlob( nSurfId, nGrpTmp)
|
||||
local nRes = EgtCurveWithRegionClassify( nLinkId, nSurfId)
|
||||
local nType = EgtGetInfo( nCurr, KEY_RIBS_TYPE, 'i')
|
||||
if nRes == GDB_CRC.INTERS or ( ( nType == RIB_TYPE.INTERNAL or nType == RIB_TYPE.SUPPORT) and nRes == GDB_CRC.OUT) or ( nType == RIB_TYPE.EXTERNAL and nRes == GDB_CRC.IN) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function CalcRibsLink( nCurr, nNext, nLoopGrp, dStrand, bForceLink, vtSlicing, nGrpTmp)
|
||||
local function CalcRibsLink( nCurr, nNext, nLoopGrp, dStrand, bForceLink, bCheckLinked, vtSlicing, nGrpTmp)
|
||||
|
||||
local ptS = EgtEP( nCurr)
|
||||
local ptE = EgtSP( nNext)
|
||||
|
||||
local nCrvId = EgtGetFirstNameInGroup( nLoopGrp, TRIM_SURF_LOOP)
|
||||
|
||||
local nCrvId = EgtGetFirstInGroup( nLoopGrp)
|
||||
-- recupero la curva di offset su cui calcolare link
|
||||
while nCrvId do
|
||||
local dParS = EgtCurveParamAtPoint( nCrvId, ptS, 10 * GEO.EPS_SMALL)
|
||||
local dParE = EgtCurveParamAtPoint( nCrvId, ptE, 10 * GEO.EPS_SMALL)
|
||||
if dParS and dParE then
|
||||
local bInvert = false
|
||||
local bClosed = EgtCurveIsClosed( nCrvId)
|
||||
if bClosed then
|
||||
-- se la curva è chiusa verifico i due percorsi possibili dParS->dParE e dParE->dParS
|
||||
local nCopyId1 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId1, dParS, dParE)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId2, dParE, dParS)
|
||||
EgtInvertCurve( nCopyId2)
|
||||
|
||||
local dLen1 = EgtCurveLength( nCopyId1)
|
||||
local dLen2 = EgtCurveLength( nCopyId2)
|
||||
if dLen1 > dLen2 then
|
||||
bInvert = true
|
||||
dParS, dParE = dParE, dParS
|
||||
end
|
||||
|
||||
-- verifico i due percorsi possibili dParS->dParE e dParE->dParS
|
||||
local nCopyId1 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId1, dParS, dParE)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId2, dParE, dParS)
|
||||
EgtInvertCurve( nCopyId2)
|
||||
|
||||
local nLinkId
|
||||
local dLen1 = EgtCurveLength( nCopyId1)
|
||||
local dLen2 = EgtCurveLength( nCopyId2)
|
||||
if dLen1 > dLen2 then
|
||||
nLinkId = nCopyId2
|
||||
EgtErase( nCopyId1)
|
||||
else
|
||||
nLinkId = nCopyId1
|
||||
EgtErase( nCopyId2)
|
||||
end
|
||||
|
||||
local nCopyId = EgtCopyGlob( nCrvId, nLoopGrp)
|
||||
local nLinkId = EgtCopyGlob( nCrvId, nCurr, GDB_IN.AFTER)
|
||||
|
||||
if dParS > dParE and not bClosed then
|
||||
bInvert = true
|
||||
dParS, dParE = dParE, dParS
|
||||
end
|
||||
|
||||
EgtTrimCurveStartEndAtParam( nLinkId, dParS, dParE)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
if bInvert then EgtInvertCurve( nLinkId) end
|
||||
|
||||
-- verifico se è valido
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp)
|
||||
if not bValid then
|
||||
EgtErase( nLinkId)
|
||||
EgtErase( nCopyId)
|
||||
return
|
||||
end
|
||||
|
||||
-- elimino dalle curve di contorno il link appena trovato
|
||||
if bClosed then
|
||||
EgtTrimCurveStartEndAtParam( nCrvId, dParE, dParS)
|
||||
EgtErase( nCopyId)
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp, bCheckLinked)
|
||||
if bValid then
|
||||
return nLinkId
|
||||
else
|
||||
if dParS < GEO.EPS_SMALL then
|
||||
-- forzare la fine della curva nel suo inizio significa cancellarla completamente
|
||||
EgtErase( nCrvId)
|
||||
else
|
||||
EgtTrimCurveEndAtParam( nCrvId, dParS)
|
||||
end
|
||||
|
||||
local _, dEnd = EgtCurveDomain( nCopyId)
|
||||
if abs( dParE - dEnd) < GEO.EPS_SMALL then
|
||||
-- forzare l'inizio della curva nella sua fine significa cancellarla completamente
|
||||
EgtErase( nCopyId)
|
||||
else
|
||||
EgtTrimCurveStartAtParam( nCopyId, dParE)
|
||||
end
|
||||
EgtErase( nLinkId)
|
||||
end
|
||||
|
||||
return nLinkId
|
||||
end
|
||||
|
||||
nCrvId = EgtGetNextName( nCrvId, TRIM_SURF_LOOP)
|
||||
nCrvId = EgtGetNext( nCrvId)
|
||||
end
|
||||
|
||||
-- se non ho trovato un collegamento sul bordo, creo una linea tra ptS e ptE
|
||||
-- se non ho trovato un collegamento lungo bordi ma link deve esserci creo una linea tra ptS e ptE
|
||||
if bForceLink then
|
||||
local nLinkId = EgtCurveCompoFromPoints( EgtGetParent( nCurr), {ptS, ptE})
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp)
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.AFTER)
|
||||
local bValid = VerifyRibsLink( nLinkId, nCurr, nNext, dStrand, nGrpTmp, bCheckLinked)
|
||||
if bValid then
|
||||
EgtSetInfo( nLinkId, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLinkId, LINK_CRV)
|
||||
EgtModifyCurveExtrusion( nLinkId, vtSlicing, GDB_RT.GLOB)
|
||||
EgtRelocateGlob( nLinkId, nCurr, GDB_IN.AFTER)
|
||||
return nLinkId
|
||||
else
|
||||
EgtErase( nLinkId)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function VerifyRibsLead( nId, nRibId, dStrand, bInVsOut, nGrpTmp)
|
||||
|
||||
local nGrp = EgtGetParent( nRibId)
|
||||
local nLeadId = EgtCopyGlob( nId, nGrp)
|
||||
if bInVsOut then
|
||||
EgtExtendCurveStartByLen( nLeadId, dStrand * 0.5)
|
||||
else
|
||||
EgtExtendCurveEndByLen( nLeadId, dStrand * 0.5)
|
||||
end
|
||||
|
||||
-- verifico che intersechi solo l'estremo corretto
|
||||
if not EgtCurveIsClosed( nRibId) then
|
||||
local pt = EgtIf( bInVsOut, EgtEP( nRibId), EgtSP( nRibId))
|
||||
local dPar = EgtCurveParamAtPoint( nLeadId, pt)
|
||||
if dPar then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
local dLen = EgtCurveLength( nId)
|
||||
if dLen < dStrand + GEO.EPS_SMALL then
|
||||
return true
|
||||
end
|
||||
|
||||
-- regione occupata dal lead
|
||||
local nLeadLoc = EgtCopyGlob( nId, nGrpTmp)
|
||||
local nOverlap = EgtGetInfo( nRibId, KEY_RIBS_OVERLAP, 'i')
|
||||
local nSrfLead = EgtSurfFrFatCurve( nGrpTmp, nId, dStrand * ( 1 - nOverlap / 100) - 100 * GEO.EPS_SMALL, false)
|
||||
if not nSrfLead then
|
||||
return false
|
||||
end
|
||||
|
||||
-- individuo eventuale lead in o link relativo al setto corrente
|
||||
local nCurrLI
|
||||
local nCurrLink
|
||||
if not bInVsOut then
|
||||
local nPrev = EgtGetPrev( nRibId)
|
||||
if nPrev and EgtGetName( nPrev) == LEAD_IN_CRV then
|
||||
nCurrLI = nPrev
|
||||
elseif nPrev and EgtGetName( nPrev) == LINK_CRV then
|
||||
nCurrLink = nPrev
|
||||
end
|
||||
end
|
||||
|
||||
local pt1 = EgtIf( bInVsOut, EgtSP( nLeadId), EgtEP( nLeadId))
|
||||
local pt2 = EgtIf( bInVsOut, EgtEP( nRibId), EgtSP( nRibId))
|
||||
if dist( pt1, pt2) < dStrand + GEO.EPS_SMALL then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
-- verifico se interseca altri setti, lead in, lead out o collegamenti
|
||||
local nCurrId = EgtGetFirstNameInGroup( EgtGetParent( nRibId), RIBS_CRV .. '*')
|
||||
-- verifico se il primo setto ha lead in da controllare
|
||||
local nPrevId = EgtGetPrev( nCurrId)
|
||||
if nPrevId and EgtGetName( nPrevId) == LEAD_IN_CRV then nCurrId = nPrevId end
|
||||
while nCurrId do
|
||||
-- salto i i wipe ( non sono materiale depositato) e i tratti relativi al setto corrente
|
||||
if not EgtStartsWith( EgtGetName( nCurrId), WIPE_CRV) and nCurrId ~= nCurrLI and nCurrId ~= nRibId and nCurrId ~= nId and nCurrId ~= nCurrLink then
|
||||
local nRibLoc = EgtCopyGlob( nCurrId, nGrpTmp)
|
||||
local nRes = EgtCurveWithRegionClassify( nRibLoc, nSrfLead)
|
||||
if nRes ~= GDB_CRC.OUT then
|
||||
return false
|
||||
end
|
||||
end
|
||||
nCurrId = EgtGetNext( nCurrId)
|
||||
end
|
||||
|
||||
local _, dParE = EgtCurveDomain( nLeadId)
|
||||
local vtDir = EgtMV( nRibId)
|
||||
-- verifiche con il setto corrente
|
||||
-- verifico non passi da altro estremo
|
||||
local dParTest = EgtCurveParamAtPoint( nLeadLoc, EgtIf( bInVsOut, EgtEP( nRibId, GDB_ID.ROOT), EgtSP( nRibId, GDB_ID.ROOT)), 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParTest then
|
||||
return false
|
||||
end
|
||||
-- verifico se tratti lineari paralleli al setto sono sufficientemente lontani
|
||||
local _, dParE = EgtCurveDomain( nLeadLoc)
|
||||
local nRibLoc = EgtCopyGlob( nRibId, nGrpTmp)
|
||||
local vtDir = EgtMV( nRibLoc)
|
||||
local dParCrv = 1
|
||||
local dTol = 10 * GEO.EPS_SMALL
|
||||
for dParCrv = 1, dParE do
|
||||
local vtS = EgtUV( nLeadId, dParCrv - 1, 1)
|
||||
local vtE = EgtUV( nLeadId, dParCrv, -1)
|
||||
-- se tratto lineare allineato con la direzione del setto verifico sia sufficientemente lontano
|
||||
if AreSameVectorApprox( vtS, vtE) and ( (vtS - vtDir):sqlen() < dTol * dTol or (vtS + vtDir):sqlen() < dTol * dTol) then
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLeadId, dParCrv - 0.5), nRibId)
|
||||
local vtS = EgtUV( nLeadLoc, dParCrv - 1, 1)
|
||||
local vtE = EgtUV( nLeadLoc, dParCrv, -1)
|
||||
local dTol = 10 * GEO.EPS_SMALL
|
||||
if AreSameVectorApprox( vtS, vtE) and ( (vtS - vtDir):sqlen() < dTol * dTol or ( vtS + vtDir):sqlen() < dTol * dTol) then
|
||||
local dDist = EgtPointCurveDist( EgtUP( nLeadLoc, dParCrv - 0.5), nRibLoc)
|
||||
EgtPoint( nGrpTmp, EgtUP( nLeadLoc, dParCrv - 0.5))
|
||||
EgtCopyGlob( nLeadLoc, nGrpTmp)
|
||||
if dDist < dStrand + GEO.EPS_SMALL then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- verifico non intersechi altri setti
|
||||
local vRibsIds = EgtGetNameInGroup( EgtGetParent( nRibId), RIBS_CRV .. '*')
|
||||
local nLeadLoc = EgtCopyGlob( nLeadId, nGrpTmp)
|
||||
for i = 1, #vRibsIds do
|
||||
if vRibsIds[i] ~= nRibId then
|
||||
local nCrvLoc = EgtCopyGlob( vRibsIds[i], nGrpTmp)
|
||||
local ptInt = EgtIP( nLeadLoc, nCrvLoc, ORIG())
|
||||
if ptInt then
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
-- verifiche con eventuale lead in
|
||||
if nCurrLI then
|
||||
local nLeadInLoc = EgtCopyGlob( nCurrLI, nGrpTmp)
|
||||
-- verifico se intersezione fra curve
|
||||
local _, nPnt, nCrv = EgtCurveCurveInters( nLeadLoc, nLeadInLoc, nGrpTmp)
|
||||
if nPnt ~= 0 or nCrv ~= 0 then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- se lead out verifico non si sovrapponga al lead in
|
||||
if not bInVsOut then
|
||||
-- recupero il lead in
|
||||
local nPrev = EgtGetPrev( nRibId)
|
||||
if nPrev and EgtGetName( nPrev) == LEAD_IN_CRV then
|
||||
local nSrfTot = EgtSurfFrFatCurve( EgtGetParent( nLeadId), nPrev, 0.5 * dStrand, false)
|
||||
if nSrfTot then
|
||||
local nRes = EgtCurveWithRegionClassify( nLeadId, nSrfTot)
|
||||
if nRes == GDB_CRC.IN or nRes == GDB_CRC.INTERS then
|
||||
EgtErase( nSrfTot)
|
||||
EgtErase( nLeadId)
|
||||
local dLeadInLen = EgtCurveLength( nLeadInLoc)
|
||||
if dLeadInLen > dStrand + GEO.EPS_SMALL then
|
||||
-- verifico di avere un solo tratto esterno di lunghezza sufficiente
|
||||
local nRes, nCnt = EgtTrimCurveWithRegion( nLeadInLoc, nSrfLead, false, false)
|
||||
if nCnt ~= 1 then
|
||||
return false
|
||||
else
|
||||
local dLen = EgtCurveLength( nRes)
|
||||
if dLen < dStrand / 2 + GEO.EPS_SMALL then
|
||||
return false
|
||||
end
|
||||
else
|
||||
nSrfTot = EgtSurfFrFatCurve( EgtGetParent( nLeadId), nLeadId, 0.5 * dStrand, false)
|
||||
if nSrfTot then
|
||||
local nRes = EgtCurveWithRegionClassify( nPrev, nSrfTot)
|
||||
if nRes == GDB_CRC.IN or nRes == GDB_CRC.INTERS then
|
||||
EgtErase( nSrfTot)
|
||||
EgtErase( nLeadId)
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
EgtErase( nSrfTot)
|
||||
end
|
||||
end
|
||||
|
||||
EgtErase( nLeadId)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
local function FindCorrectRibsLead( dPar, nCrv, nCrvOffs, bLeadInvert, dLeadLen, dStrand, bInVsOut, nGrpTmp)
|
||||
---------------------------------------------------------------------------------
|
||||
local function PrepareRibLead( nCrvOffs, nRib, bInvert, bInVsOut, dPar, dLeadLen)
|
||||
|
||||
local nLeadId = EgtCopyGlob( nCrvOffs, nRib, EgtIf( bInVsOut, GDB_IN.BEFORE, GDB_IN.AFTER))
|
||||
EgtChangeClosedCurveStart( nLeadId, dPar)
|
||||
-- oriento in modo che la curva parta da nRib
|
||||
if bInvert then
|
||||
EgtInvertCurve( nLeadId)
|
||||
end
|
||||
EgtTrimCurveEndAtLen( nLeadId, dLeadLen)
|
||||
if bInVsOut then
|
||||
-- se lead in la curva deve terminare in nRib
|
||||
EgtInvertCurve( nLeadId)
|
||||
end
|
||||
return nLeadId
|
||||
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------------------
|
||||
local function FindCorrectRibLead( dPar, nRib, nCrvOffs, bLeadInvert, dLeadLen, dStrand, bInVsOut, nGrpTmp, bSpecialCase)
|
||||
|
||||
local nLeadId
|
||||
local bInvert = bLeadInvert -- valore di default è quello settato nel file dei parametri
|
||||
local bInvert = bLeadInvert -- valore di default è quello dei parametri
|
||||
local bOnlyOneSide = false
|
||||
local dParE
|
||||
|
||||
local _, dParEnd = EgtCurveDomain( nCrvOffs)
|
||||
local bClosed = EgtCurveIsClosed( nCrvOffs)
|
||||
local bOnlyOneCurve = not bClosed and ( dPar < GEO.EPS_SMALL or abs( dPar - dParEnd) < GEO.EPS_SMALL)
|
||||
|
||||
local nMainCrv = nCrvOffs -- curva preferita da utilizzare per lead in
|
||||
local nOtherCrv -- altra possibile curva da ultizzare nel caso nMainCrv non sia adatta
|
||||
|
||||
if bClosed then
|
||||
EgtChangeClosedCurveStart( nCrvOffs, dPar)
|
||||
nOtherCrv = nCrvOffs
|
||||
elseif not bOnlyOneCurve then
|
||||
nOtherCrv = EgtSplitCurveAtParam( nCrvOffs, dPar)
|
||||
-- verifico se ho un solo lato possibile per la presenza di altre passate
|
||||
local nOtherRib
|
||||
if bSpecialCase then
|
||||
local sName = EgtGetName( nRib)
|
||||
local nFirst = EgtGetFirstNameInGroup( EgtGetParent( nRib), sName)
|
||||
local nLast = EgtGetLastNameInGroup( EgtGetParent( nRib), sName)
|
||||
if bInVsOut and nRib == nFirst then
|
||||
nOtherRib = nLast
|
||||
elseif not bInVsOut and nRib == nLast then
|
||||
nOtherRib = nFirst
|
||||
end
|
||||
else
|
||||
local nLinkId = EgtIf( bInVsOut, EgtGetNext( nRib), EgtGetPrev( nRib))
|
||||
if nLinkId and EgtGetName( nLinkId) == LINK_CRV then
|
||||
nOtherRib = EgtIf( bInVsOut, EgtGetNext( nLinkId), EgtGetPrev( nLinkId))
|
||||
local nOrigRib1 = EgtGetInfo( nRib, KEY_ORIGINAL_RIB, 'i')
|
||||
local nOrigRib2 = EgtGetInfo( nOtherRib, KEY_ORIGINAL_RIB, 'i')
|
||||
if nOrigRib1 ~= nOrigRib2 then
|
||||
nOtherRib = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- calcolo del parametro bInvert
|
||||
if bOnlyOneCurve then
|
||||
-- invert dipende dall'estremo da cui parte il setto
|
||||
bInvert = abs( dPar - dParEnd) < GEO.EPS_SMALL
|
||||
elseif not bClosed then
|
||||
-- invert può essere legato anche alla lunghezza dei tratti possibili
|
||||
local dLen1 = EgtCurveLength( nMainCrv)
|
||||
local dLen2 = EgtCurveLength( nOtherCrv)
|
||||
if dLen1 > dLeadLen - GEO.EPS_SMALL and dLen2 < dLeadLen - GEO.EPS_SMALL then
|
||||
bInvert = true
|
||||
elseif dLen1 < dLeadLen - GEO.EPS_SMALL and dLen2 > dLeadLen - GEO.EPS_SMALL then
|
||||
bInvert = false
|
||||
end
|
||||
|
||||
if not bInvert then
|
||||
nMainCrv, nOtherCrv = nOtherCrv, nMainCrv
|
||||
if nOtherRib then
|
||||
local ptOther = EgtIf( bInVsOut, EgtEP( nOtherRib, GDB_ID.ROOT), EgtSP( nOtherRib, GDB_ID.ROOT))
|
||||
dParE = EgtCurveParamAtPoint( nCrvOffs, ptOther, 100 * GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParE then
|
||||
bOnlyOneSide = true
|
||||
end
|
||||
end
|
||||
|
||||
-- primo tentativo con la curva favorita
|
||||
nLeadId = EgtCopyGlob( nMainCrv, nCrv, EgtIf( bInVsOut, GDB_IN.BEFORE, GDB_IN.AFTER))
|
||||
if bInvert then EgtInvertCurve( nLeadId) end
|
||||
EgtTrimCurveEndAtLen( nLeadId, dLeadLen)
|
||||
if bInVsOut then EgtInvertCurve( nLeadId) end
|
||||
if VerifyRibsLead( nLeadId, nCrv, dStrand, bInVsOut, nGrpTmp) then
|
||||
-- se valido aggiorno le curve per prossimi lead in/out
|
||||
if bInvert then
|
||||
EgtTrimCurveEndAtLen( nMainCrv, EgtCurveLength( nCrvOffs) - dLeadLen)
|
||||
else
|
||||
EgtTrimCurveStartAtLen( nMainCrv, dLeadLen)
|
||||
end
|
||||
elseif not nOtherCrv then
|
||||
-- se non è valido e non ho altre curve possibili cancello
|
||||
EgtErase( nLeadId)
|
||||
return nil
|
||||
-- se un solo lato possibile
|
||||
if bOnlyOneSide then
|
||||
|
||||
-- verifico a quale valore di bInvert corrisponde l'unico lato possibile
|
||||
local nCopyId1 = EgtCopyGlob( nCrvOffs, nGrpTmp)
|
||||
local nCopyId2 = EgtCopyGlob( nCrvOffs, nGrpTmp)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId1, dPar, dParE)
|
||||
EgtTrimCurveStartEndAtParam( nCopyId2, dParE, dPar)
|
||||
local dLen1 = EgtCurveLength( nCopyId1)
|
||||
local dLen2 = EgtCurveLength( nCopyId2)
|
||||
bInvert = dLen1 < dLen2
|
||||
|
||||
nLeadId = PrepareRibLead( nCrvOffs, nRib, bInvert, bInVsOut, dPar, dLeadLen)
|
||||
-- verifico se lead sensato
|
||||
if not VerifyRibsLead( nLeadId, nRib, dStrand, bInVsOut, nGrpTmp) then
|
||||
EgtErase( nLeadId)
|
||||
return
|
||||
end
|
||||
|
||||
-- se due lati possibili
|
||||
else
|
||||
-- se non è valido ma ho altra curva possibile, tento con quella
|
||||
EgtErase( nLeadId)
|
||||
nLeadId = EgtCopyGlob( nOtherCrv, nCrv, EgtIf( bInVsOut, GDB_IN.BEFORE, GDB_IN.AFTER))
|
||||
if not bInvert then EgtInvertCurve( nLeadId) end
|
||||
EgtTrimCurveEndAtLen( nLeadId, dLeadLen)
|
||||
if bInVsOut then EgtInvertCurve( nLeadId) end
|
||||
if VerifyRibsLead( nLeadId, nCrv, dStrand, bInVsOut, nGrpTmp) then
|
||||
if bInvert then
|
||||
EgtTrimCurveStartAtLen( nOtherCrv, dLeadLen)
|
||||
else
|
||||
EgtTrimCurveEndAtLen( nOtherCrv, EgtCurveLength( nCrvOffs) - dLeadLen)
|
||||
end
|
||||
else
|
||||
-- primo tentativo nella direzione individuata dal parametro bInvert
|
||||
nLeadId = PrepareRibLead( nCrvOffs, nRib, bInvert, bInVsOut, dPar, dLeadLen)
|
||||
if not VerifyRibsLead( nLeadId, nRib, dStrand, bInVsOut, nGrpTmp) then
|
||||
-- secondo tentativo nell'altra direzione
|
||||
EgtErase( nLeadId)
|
||||
bInvert = not bInvert
|
||||
return nil
|
||||
nLeadId = PrepareRibLead( nCrvOffs, nRib, bInvert, bInVsOut, dPar, dLeadLen)
|
||||
if not VerifyRibsLead( nLeadId, nRib, dStrand, bInVsOut, nGrpTmp) then
|
||||
EgtErase( nLeadId)
|
||||
return
|
||||
end
|
||||
end
|
||||
-- aggiorno parametro bInvert
|
||||
bInvert = not bInvert
|
||||
end
|
||||
|
||||
|
||||
return nLeadId, bInvert
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRibsLeadIn( nCrv, nLoopsGrp, dStrand, vtSlicing, nGrpTmp)
|
||||
|
||||
local function AddRibsLeadIn( nCrv, nLoopsGrp, dStrand, vtSlicing, nGrpTmp, bForceNoSolidBorder, bSpecialCase)
|
||||
|
||||
local dLILen = EgtGetInfo( nCrv, KEY_RIBS_LEAD_IN_LEN, 'd')
|
||||
local bLIInvert = EgtGetInfo( nCrv, KEY_RIBS_LEAD_IN_INVERT, 'b')
|
||||
|
||||
@@ -880,27 +898,30 @@ local function AddRibsLeadIn( nCrv, nLoopsGrp, dStrand, vtSlicing, nGrpTmp)
|
||||
|
||||
-- recupero la curva di offset su cui calcolare leadin
|
||||
local ptS = EgtSP( nCrv)
|
||||
local nCrvOffs = EgtGetFirstInGroup( nLoopsGrp)
|
||||
while nCrvOffs do
|
||||
local dParS = EgtCurveParamAtPoint( nCrvOffs, ptS)
|
||||
local vCrvOffs = {}
|
||||
if bForceNoSolidBorder then
|
||||
vCrvOffs = EgtGetNameInGroup( nLoopsGrp, SURF_LOOP .. '*') or {}
|
||||
else
|
||||
vCrvOffs = EgtGetAllInGroup( nLoopsGrp) or {}
|
||||
end
|
||||
|
||||
for i = 1, #vCrvOffs do
|
||||
local dParS = EgtCurveParamAtPoint( vCrvOffs[i], ptS)
|
||||
if dParS then
|
||||
|
||||
local nLeadIn = FindCorrectRibsLead( dParS, nCrv, nCrvOffs, bLIInvert, dLILen, dStrand, true, nGrpTmp)
|
||||
local nLeadIn = FindCorrectRibLead( dParS, nCrv, vCrvOffs[i], bLIInvert, dLILen, dStrand, true, nGrpTmp, bSpecialCase)
|
||||
-- se lead in possibile
|
||||
if nLeadIn then
|
||||
EgtModifyCurveExtrusion( nLeadIn, vtSlicing, GDB_RT.GLOB)
|
||||
EgtSetInfo( nLeadIn, KEY_TYPE, TYPE.RIB)
|
||||
EgtSetName( nLeadIn, LEAD_IN_CRV)
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
nCrvOffs = EgtGetNext( nCrvOffs)
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------
|
||||
local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, nGrpTmp, bForceNoBorder)
|
||||
local function AddRibsLeadOut( nCrv, nLoopsGrp, dStrand, vtSlicing, nGrpTmp, bForceNoSolidBorder, bSpecialCase)
|
||||
|
||||
local dRibsLOLen = EgtGetInfo( nCrv, KEY_RIBS_LEAD_OUT_LEN, 'd')
|
||||
local dRibsLOCoasting = EgtGetInfo( nCrv, KEY_RIBS_LEAD_OUT_COASTING, 'd')
|
||||
@@ -909,11 +930,11 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, n
|
||||
local bRibsLOInvert = EgtGetInfo( nCrv, KEY_RIBS_LEAD_OUT_INVERT, 'b')
|
||||
|
||||
if abs( dRibsLOLen) < GEO.EPS_SMALL and
|
||||
abs( dRibsLOCoasting) < GEO.EPS_SMALL and
|
||||
abs( dRibsLOCoasting) < GEO.EPS_SMALL and
|
||||
abs( dRibsLOWipe) < GEO.EPS_SMALL then return end
|
||||
|
||||
-- se setto chiuso oppure non deve stare sul bordo (rib unbounded) applico la stessa uscita delle shell
|
||||
if EgtCurveIsClosed( nCrv) or bForceNoBorder then
|
||||
-- se setto chiuso applico la stessa uscita delle shell
|
||||
if EgtCurveIsClosed( nCrv) then
|
||||
return AddRetraction( nCrv, vtSlicing, dRibsLOCoasting, dRibsLOWipe, dRibsLOWipeAng)
|
||||
end
|
||||
|
||||
@@ -921,9 +942,15 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, n
|
||||
local vtE = EgtEV( nCrv, GDB_ID.ROOT)
|
||||
|
||||
-- recupero la curva di offset su cui calcolare lead out
|
||||
local nCrvOffs = EgtGetFirstInGroup( nLoopsGrp)
|
||||
while nCrvOffs do
|
||||
local dParE = EgtCurveParamAtPoint( nCrvOffs, ptE, GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
local vCrvOffs = {}
|
||||
if bForceNoSolidBorder then
|
||||
vCrvOffs = EgtGetNameInGroup( nLoopsGrp, SURF_LOOP .. '*') or {}
|
||||
else
|
||||
vCrvOffs = EgtGetAllInGroup( nLoopsGrp) or {}
|
||||
end
|
||||
|
||||
for i = 1, #vCrvOffs do
|
||||
local dParE = EgtCurveParamAtPoint( vCrvOffs[i], ptE, GEO.EPS_SMALL, GDB_RT.GLOB)
|
||||
if dParE then
|
||||
|
||||
local nCrvLO
|
||||
@@ -931,15 +958,12 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, n
|
||||
local nWipe
|
||||
|
||||
-- trovo curva opportuna per lead out
|
||||
local nCrvRef, bInvert = FindCorrectRibsLead( dParE, nCrv, nCrvOffs, bRibsLOInvert, dRibsLOLen + dRibsLOCoasting, dStrand, false, nGrpTmp)
|
||||
local nCrvRef, bInvert = FindCorrectRibLead( dParE, nCrv, vCrvOffs[i], bRibsLOInvert, dRibsLOLen + dRibsLOCoasting, dStrand, false, nGrpTmp, bSpecialCase)
|
||||
|
||||
if nCrvRef then
|
||||
-- verifico se la curva ha lunghezza sufficiente
|
||||
local dLen = EgtCurveLength( nCrvRef)
|
||||
local bSkip = ( dLen - dRibsLOLen - dRibsLOCoasting < - GEO.EPS_SMALL)
|
||||
|
||||
-- primo tratto ( segue offset con flusso aperto)
|
||||
if dRibsLOLen > GEO.EPS_SMALL and not bSkip then
|
||||
if dRibsLOLen > GEO.EPS_SMALL then
|
||||
nCrvLO = EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER)
|
||||
EgtTrimCurveEndAtLen( nCrvLO, dRibsLOLen)
|
||||
EgtModifyCurveExtrusion( nCrvLO, vtSlicing, GDB_RT.GLOB)
|
||||
@@ -974,21 +998,17 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, n
|
||||
if nType == RIB_TYPE.EXTERNAL then dAng = - dAng end
|
||||
vtE:rotate( vtSlicing, EgtIf( bInvert, - dAng, dAng))
|
||||
local ptFinal = FindWipeEndPoint( ptE, vtE, dRibsLOWipe, vtSlicing)
|
||||
nWipe = EgtCurveCompoFromPoints( nTPathGrp, { ptE, ptFinal}, GDB_RT.GLOB)
|
||||
nWipe = EgtCurveCompoFromPoints( EgtGetParent( nCrv), { ptE, ptFinal}, GDB_RT.GLOB)
|
||||
EgtModifyCurveExtrusion( nWipe, vtSlicing, GDB_RT.GLOB)
|
||||
EgtRelocateGlob( nWipe, nCoasting or nCrvLO or nCrv, GDB_IN.AFTER)
|
||||
EgtSetName( nWipe, WIPE_CRV)
|
||||
EgtSetInfo( nWipe, KEY_TYPE, TYPE.WIPE)
|
||||
EgtSetColor( nWipe, EgtStdColor('AQUA'))
|
||||
end
|
||||
else
|
||||
-- aggiungo coasting e wipe come sulle shell normali
|
||||
AddRetraction( nCrv, vtSlicing, dRibsLOCoasting, dRibsLOWipe, dRibsLOWipeAng)
|
||||
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
nCrvOffs = EgtGetNext( nCrvOffs)
|
||||
end
|
||||
|
||||
-- se non ho trovato curva sul bordo su cui fare il lead out aggiungo coasting e wipe come sulle shell normali
|
||||
@@ -1038,21 +1058,17 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
else
|
||||
local bLoopRib = EgtGetInfo( tabRibs[i][1], KEY_LOOP_RIB, 'b') or false
|
||||
for j = 1, #tabRibs[i] - 1 do
|
||||
local bUserLink = EgtGetInfo( tabRibs[i][j], KEY_RIBS_USER_LINK, 'b') or false
|
||||
local bUserLink = ( EgtGetInfo( tabRibs[i][j], KEY_RIBS_USER_LINK, 'b') or false) and ( EgtGetInfo( tabRibs[i][j+1], KEY_RIBS_USER_LINK, 'b') or false)
|
||||
local nOrig1 = EgtGetInfo( tabRibs[i][j], KEY_ORIGINAL_RIB, 'i') or 0
|
||||
local nOrig2 = EgtGetInfo( tabRibs[i][j + 1], KEY_ORIGINAL_RIB, 'i') or 0
|
||||
local nSplitId1 = EgtGetInfo( tabRibs[i][j], KEY_SPLIT_ID, 'i') or 0
|
||||
local nSplitId2 = EgtGetInfo( tabRibs[i][j + 1], KEY_SPLIT_ID, 'i') or 0
|
||||
local bForceLink = ( nOrig1 == nOrig2)
|
||||
local bForceLink = ( nOrig1 == nOrig2 and nSplitId1 == nSplitId2)
|
||||
local bCheckLinkedRibs = not bForceLink and not bUserLink
|
||||
|
||||
if ( nOrig1 ~= nOrig2 and bUserLink) or ( nSplitId1 == nSplitId2 and nOrig1 == nOrig2) then
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, LayerParams.dStrand, bForceLink, LayerParams.vtSlicing, nGrpTmp)
|
||||
-- creo link fittizio per eliminare tratto corrispondente sulla curva di offset
|
||||
if not bSpecialCase and bForceLink then
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][j + 1], tabRibs[i][j], nLoopGrp, LayerParams.dStrand, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][j], tabRibs[i][j + 1], nLoopGrp, LayerParams.dStrand, bForceLink, bCheckLinkedRibs, LayerParams.vtSlicing, nGrpTmp)
|
||||
|
||||
-- se LoopRib congiungo i setti in unico percorso
|
||||
if bLoopRib and nLinkId then
|
||||
EgtAddCurveCompoCurve( tabRibs[i][j], nLinkId)
|
||||
@@ -1065,7 +1081,7 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
-- se LoopRib aggiungo collegamento tra primo e ultimo setto del gruppo
|
||||
if bLoopRib then
|
||||
local nTotCrv = #tabRibs[i]
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][nTotCrv], tabRibs[i][1], nLoopGrp, LayerParams.dStrand, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
local nLinkId = CalcRibsLink( tabRibs[i][nTotCrv], tabRibs[i][1], nLoopGrp, LayerParams.dStrand, false, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
if nLinkId then
|
||||
-- se curva unica
|
||||
if tabRibs[i][nTotCrv] == tabRibs[i][1] then
|
||||
@@ -1085,11 +1101,6 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if bSpecialCase then
|
||||
local nFakeLink = CalcRibsLink( tabRibs[i][#tabRibs[i]], tabRibs[i][1], nLoopGrp, LayerParams.dStrand, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
EgtErase( nFakeLink)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1099,36 +1110,35 @@ local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams)
|
||||
local bLink2 = EgtGetInfo( tabRibs[i + 1][1], KEY_RIBS_LINK, 'b')
|
||||
if bLink1 and bLink2 then
|
||||
local nCnt = #tabRibs[i]
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, LayerParams.dStrand, false, LayerParams.vtSlicing, nGrpTmp)
|
||||
CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, LayerParams.dStrand, false, true, LayerParams.vtSlicing, nGrpTmp)
|
||||
end
|
||||
end
|
||||
|
||||
-- leadin/leadout
|
||||
local bForceNoBorder = false
|
||||
local bForceNoSolidBorder = false
|
||||
local nType = EgtGetInfo( vEntIds[1], KEY_RIBS_TYPE, 'i')
|
||||
if nType == RIB_TYPE.UNBOUNDED then
|
||||
bForceNoBorder = true
|
||||
bForceNoSolidBorder = true
|
||||
end
|
||||
local nCrvRib = nNewFirstEnt
|
||||
while nCrvRib do
|
||||
-- verifico se necessario lead in
|
||||
local nPrev = EgtGetPrev( nCrvRib)
|
||||
if ( not nPrev or EgtGetName( nPrev) ~= LINK_CRV) and not bForceNoBorder then
|
||||
AddRibsLeadIn( nCrvRib, nLoopGrp, LayerParams.dStrand, LayerParams.vtSlicing, nGrpTmp)
|
||||
if not nPrev or EgtGetName( nPrev) ~= LINK_CRV then
|
||||
AddRibsLeadIn( nCrvRib, nLoopGrp, LayerParams.dStrand, LayerParams.vtSlicing, nGrpTmp, bForceNoSolidBorder, bSpecialCase)
|
||||
end
|
||||
-- verifico se necessario lead out
|
||||
local nNext = EgtGetNext( nCrvRib)
|
||||
if not nNext or EgtGetName( nNext) ~= LINK_CRV then
|
||||
AddRibsLeadOut( nCrvRib, nTpathGrpId, nLoopGrp, LayerParams.vtSlicing, LayerParams.dStrand, nGrpTmp, bForceNoBorder)
|
||||
AddRibsLeadOut( nCrvRib, nLoopGrp, LayerParams.dStrand, LayerParams.vtSlicing, nGrpTmp, bForceNoSolidBorder, bSpecialCase)
|
||||
end
|
||||
nCrvRib = EgtGetNextName( nCrvRib, RIBS_CRV .. '*')
|
||||
end
|
||||
|
||||
EgtErase( nGrpTmp)
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
--------------------------------------------------------------------
|
||||
------------------------- SPIRAL VASE ------------------------------
|
||||
--------------------------------------------------------------------
|
||||
local function AddSpiralVaseLeadOut( nOldId, LayerParams)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
-- RunGcodeGenerate.lua by Egaltech s.r.l. 2023/02/02
|
||||
-- RunGcodeGenerate.lua by Egaltech s.r.l. 2023/04/11
|
||||
-- Calcoli prima fase per Stampa 3d
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
@@ -131,7 +131,7 @@ function RunGcodeGenerate.Exec()
|
||||
|
||||
-- Salvo il progetto
|
||||
local sFilePath = EgtGetCurrFilePath()
|
||||
sFilePath = EgtChangePathExtension( sFilePath, 'nge')
|
||||
sFilePath = EgtChangePathExtension( sFilePath, 'icrs')
|
||||
EgtSetCurrFilePath( sFilePath)
|
||||
EgtSaveFile()
|
||||
|
||||
|
||||
@@ -66,6 +66,12 @@ local function RemoveOldSlices( nPartId)
|
||||
EgtErase( vOldSliceId[i])
|
||||
end
|
||||
end
|
||||
|
||||
-- rimuovo gruppo con i loop dei setti
|
||||
local nRibsLoopsGrp = EgtGetFirstNameInGroup( nPartId, RIBS_LOOP_GRP)
|
||||
if nRibsLoopsGrp then
|
||||
EgtErase( nRibsLoopsGrp)
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
-- Version.lua by Egaltech s.r.l. 2023/02/28
|
||||
-- Gestione della versione di 3dPrinting
|
||||
|
||||
VERSION = '2.5c2'
|
||||
VERSION = '2.5e2'
|
||||
Reference in New Issue
Block a user