From 4225985a61da1c1b0c2ee7010b3fd6b3a03f559b Mon Sep 17 00:00:00 2001 From: SaraP Date: Tue, 6 Jun 2023 17:11:09 +0200 Subject: [PATCH] 3dPrinting : - aggiunta approssimazione delle curve dopo slicing ( per evitare caso di fallimento offset) - migliorata segnalazione errori. --- LuaLibs/CalcPaths.lua | 24 ++++++++++++------------ LuaLibs/CalcSlices.lua | 9 +++++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/LuaLibs/CalcPaths.lua b/LuaLibs/CalcPaths.lua index 0336a37..690e496 100644 --- a/LuaLibs/CalcPaths.lua +++ b/LuaLibs/CalcPaths.lua @@ -2257,7 +2257,7 @@ local function CreateShellNbrSurfaces( nGrp, nShellsNbr) end else EgtOutLog( 'Error: ReducedShellNumber is not closed (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : ReducedShellNumber is not closed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : ReducedShellNumber is not closed') end nCrvId = EgtGetNextName( nCrvId, SHELL_NBR_CRV .. '*') @@ -2295,7 +2295,7 @@ local function CreateShellNbrSurfaces( nGrp, nShellsNbr) end if not bOk then EgtOutLog( 'Error: ReducedShellNumber is not considered (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : ReducedShellNumber is not considered') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : ReducedShellNumber is not considered') end end EgtSetName( nSrfId, SHELL_NBR_SURF .. EgtNumToString( nDiff)) @@ -2618,11 +2618,11 @@ local function UpdateTrimSurfWithAuxSolidsOffset( nSrfSolid, nSrfBase, dStrand, local bOk, bExists, nSrfOffs = ComputeSurfOffset( nSrfSolid, nCrvGrp, dStrand, vtSlicing) if not bOk then EgtOutLog( 'Error : creation of AuxSolid region for TotTrimSurfRegion failed (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') elseif nSrfOffs then if not EgtSurfFrSubtract( nSrfBase, nSrfOffs) then EgtOutLog( 'Error : EgtSurfFrSubtract with AuxSolid for TotTrimSurfRegion failed (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') end EgtErase( nSrfOffs) end @@ -2694,7 +2694,7 @@ local function UpdateTrimSurfWithAuxSolidsZigZag( nAuxSolidsGrp, sName, nSrfBase -- aggiorno la TotShellSurfForTrim if not EgtSurfFrSubtract( nSrfBase, nSrfZigZag) then EgtOutLog( 'Error : EgtSurfFrSubtract with AuxSolid for TotTrimSurfRegion failed (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : error in computing region for internal elements') end end EgtErase( nGrpTmp) @@ -2852,7 +2852,7 @@ local function CalcAuxSolidsPaths( nSliceGrp, nSolidGrp, LayerParams, vPtStart) end else EgtOutLog( 'Error : creation of AuxSolid region failed (layer '.. EgtNumToString( s_nCurrIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( s_nCurrIdx) .. ' : creation of AuxSolid region failed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( s_nCurrIdx) .. ' : creation of AuxSolid region failed') end end end @@ -2931,7 +2931,7 @@ function CalcPaths.Exec( nPartId) local bOk, bExists, nSrfId = ComputeSurfOffset( nSrf, nCrvGrpId, - dOffs, LayerParams.vtSlicing) if not bOk then EgtOutLog( 'Error : ExtOffset failed (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( nIdx) .. ' : creation of OuterShell failed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( nIdx) .. ' : creation of OuterShell failed') elseif not bExists then EgtOutLog( 'Warning : ExtOffset not possible (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') else @@ -2956,7 +2956,7 @@ function CalcPaths.Exec( nPartId) local bOk, bExists, nSrfId = ComputeSurfOffset( nSrf, nCrvGrpId, - dOffs, LayerParams.vtSlicing) if not bOk then EgtOutLog( 'Error : IntOffset failed (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( nIdx) .. ' : creation of InnerShell failed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( nIdx) .. ' : creation of InnerShell failed') elseif not bExists then EgtOutLog( 'Warning : IntOffset ' .. EgtNumToString( nInd) .. ' not possible (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') else @@ -2969,7 +2969,7 @@ function CalcPaths.Exec( nPartId) if not bPrevExists then local sElement = EgtIf( nInd > 1, 'IntOffset ' .. EgtNumToString( nInd - 1), 'ExtOffset') EgtOutLog( 'Error :' .. sElement .. ' failed (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( nIdx) .. ' : creation of ' .. EgtIf( nInd > 1, 'InnerShell', 'OuterShell') .. ' failed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( nIdx) .. ' : creation of ' .. EgtIf( nInd > 1, 'InnerShell', 'OuterShell') .. ' failed') end end @@ -2986,7 +2986,7 @@ function CalcPaths.Exec( nPartId) local bOkTrim, bExistsTrim, nSrfTrim = ComputeSurfOffset( nSrf, nCrvGrpId, - dSurfTrimOffs, LayerParams.vtSlicing) if not bOkTrim then EgtOutLog( 'Error : IntOffset for TotTrimSurfRegion failed (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( nIdx) .. ' : error in computing region for internal elements') + table.insert( s_vErr, 'layer ' .. EgtNumToString( nIdx) .. ' : error in computing region for internal elements') elseif bExistsTrim then EgtSetName( nSrfTrim, TOT_SHELL_TRIM_SURF) EgtSetStatus( nSrfTrim, GDB_ST.OFF) @@ -2994,7 +2994,7 @@ function CalcPaths.Exec( nPartId) -- se questo offset esiste ma il precedente no, allora il precedente รจ un errore da segnalare if not bPrevExists then EgtOutLog( 'Error : IntOffset' .. EgtNumToString( LayerParams.nShellsNbr - 1 - nMaxShellNbrDiff) .. ' failed (layer '.. EgtNumToString( nIdx) ..') - CalcPaths') - table.insert( s_vErr, EgtNumToString( nIdx) .. ' : creation of InnerShell failed') + table.insert( s_vErr, 'layer ' .. EgtNumToString( nIdx) .. ' : creation of InnerShell failed') end end @@ -3039,7 +3039,7 @@ function CalcPaths.Exec( nPartId) end if #s_vErr > 0 then - EgtOutBox( 'CalcPath Error on layers :\n' .. table.concat( s_vErr, '\n'), 'Calculating Paths') + EgtOutBox( 'CalcPath Error on :\n' .. table.concat( s_vErr, '\n'), 'Calculating Paths') end return true diff --git a/LuaLibs/CalcSlices.lua b/LuaLibs/CalcSlices.lua index ce4e54e..6c4e716 100644 --- a/LuaLibs/CalcSlices.lua +++ b/LuaLibs/CalcSlices.lua @@ -169,7 +169,7 @@ local function SliceStm( vIds, nLayId, vtSlicing, nType, sName, sNameGrp, tabPar local dZ = EgtGetInfo( nLayId, KEY_SLICE_REAL_Z, 'd') local dDeltaZ = EgtGetInfo( nLayId, KEY_SLICE_DELTAZ, 'd') local nLayCnt = EgtGetInfo( nLayId, KEY_SLICE_NBR, 'i') - + for i = 1, #vIds do -- verifico che oggetto sia trimesh local nTypeObj = EgtGetType( vIds[i]) @@ -213,7 +213,7 @@ local function SliceStm( vIds, nLayId, vtSlicing, nType, sName, sNameGrp, tabPar 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 + for nId = nChainId, nChainId + nCnt - 1 do EgtSetName( nId, sName .. tostring( i)) EgtMove( nId, - ( dDeltaZ + dCorr) * vtSlicing) EgtSetInfo( nId, KEY_ORIGINAL_SURF, vIds[i]) @@ -222,7 +222,8 @@ local function SliceStm( vIds, nLayId, vtSlicing, nType, sName, sNameGrp, tabPar EgtSetInfo( nId, sKey, sVal) end end - + EgtModifyCurveExtrusion( nId, vtSlicing) + EgtApproxCurve( nId, GDB_CA.ARCS, MID_TOLER) -- se ho ancora curve aperte, segnalo errore if nType ~= TYPE.RIB and nType ~= TYPE.INFILL and not EgtCurveIsClosed( nId) then EgtOutLog( 'Error : hole in object (layer '.. EgtNumToString( nLayCnt) ..') - CalcSlices') @@ -242,7 +243,7 @@ local function SliceStm( vIds, nLayId, vtSlicing, nType, sName, sNameGrp, tabPar if not EgtGetFirstInGroup( nGrp) then EgtErase( nGrp) end - + end --------------------------------------------------------------------