diff --git a/LuaLibs/AddManData.lua b/LuaLibs/AddManData.lua index bdfa5c7..aead0aa 100644 --- a/LuaLibs/AddManData.lua +++ b/LuaLibs/AddManData.lua @@ -97,7 +97,6 @@ KEY_RIBS_LEAD_OUT_LEN = "RibsLeadOutLen" KEY_RIBS_LEAD_OUT_COASTING = "RibsLeadOutCoasting" KEY_RIBS_LEAD_OUT_WIPE = "RibsLeadOutWipe" KEY_RIBS_LEAD_OUT_WIPE_DIR = "RibsLeadOutWipeDir" -KEY_RIBS_PRINT_ORDER = "RibsPrintOrder" KEY_RIBS_INTERS = "RibsHaveIntersections" KEY_RIBS_SPECIAL_CASE = "RibsSpecialCase" KEY_SPLIT_ORDER = "SplitOrder" diff --git a/LuaLibs/CalcPaths.lua b/LuaLibs/CalcPaths.lua index 7ba16ae..a56a3dc 100644 --- a/LuaLibs/CalcPaths.lua +++ b/LuaLibs/CalcPaths.lua @@ -22,6 +22,7 @@ local function GetLayerParamsForPathCalc() LayerParams.bSpiralVase = EgtGetInfo( s_nPartId, KEY_SPIRAL_VASE, 'b') or false LayerParams.nShellsNbr = EgtGetInfo( s_nPartId, KEY_SHELLS_NBR, 'i') LayerParams.dStrand = EgtGetInfo( s_nPartId, KEY_STRAND, 'd') + LayerParams.dLayHeight = EgtGetInfo( s_nPartId, KEY_SLICE_STEP, 'd') LayerParams.nStrandOverlap = EgtGetInfo( s_nPartId, KEY_STRAND_OVERLAP, 'i') or 0 LayerParams.dOffs = EgtGetInfo( s_nPartId, KEY_OFFSET_SLICE, 'd') LayerParams.nFloorNbr = EgtGetInfo( s_nPartId, KEY_FLOOR_NBR, 'i') or 0 @@ -30,9 +31,9 @@ local function GetLayerParamsForPathCalc() LayerParams.nCeilType = EgtGetInfo( s_nPartId, KEY_CEIL_TYPE, 'i') or INFILL_TYPE.ZIGZAG LayerParams.vtSlicing = EgtGetInfo( s_nPartId, KEY_SLICING_DIR, 'v') LayerParams.bPrintInvert = ( EgtGetInfo( s_nPartId, KEY_PRINT_DIRECTION, 'i') == PRINT_DIRECTION.CW) + LayerParams.vPrintOrder = EgtGetInfo( s_nPartId, KEY_PRINT_ORDER, 'vi') or { 1, 2, 3, 4, 5, 6, 7, 8} -- parametri costolature LayerParams.bRibsInvertOrder = EgtGetInfo( s_nPartId, KEY_RIBS_INVERT_ORDER, 'b') - LayerParams.vRibsPrintOrder = EgtGetInfo( s_nPartId, KEY_RIBS_PRINT_ORDER, 'vi') or {3, 1, 4, 2} -- parametri regioni con diverse passate LayerParams.dShellNbrCoasting = EgtGetInfo( s_nPartId, KEY_SHELL_NBR_COASTING, 'd') LayerParams.dShellNbrWipe = EgtGetInfo( s_nPartId, KEY_SHELL_NBR_WIPE, 'd') @@ -488,7 +489,10 @@ local function CheckRibUserLink( nCrv, nCnt, vtSlicing) EgtCloseCurveCompo( nSrfLoop) local nSurf = EgtSurfFlatRegion( nGrpTmp, {nSrfLoop}) - if not nSurf then return end + if not nSurf then + EgtErase( nGrpTmp) + return + end -- verifico direzione della normale local vtN = EgtSurfFrNormVersor( nSurf, GDB_ID.ROOT) if AreSameVectorApprox( vtN, vtSlicing) then @@ -825,12 +829,9 @@ local function AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nOffs end end - EgtChangeId( nId, vOffs2[i]) -- aggiorno ordine di split copiandolo da nCrv2 - CopyInfo( nCrv2, vOffs2[i], KEY_SPLIT_ORDER, 'i') - for j = nId + nCnt - 1, nId + 1, -1 do - CopyInfo( nCrv2, j, KEY_SPLIT_ORDER, 'i') -- ordine di split - EgtRelocateGlob( j, j - 1, GDB_IN.AFTER) + for j = nId, nId + nCnt - 1 do + CopyInfo( nCrv2, j, KEY_SPLIT_ORDER, 'i') end end @@ -1197,7 +1198,7 @@ local function ShortestPathForRibs( vRibs, nGrp, bInvertOrder) end -------------------------------------------------------------------- -local function ReorderRibs( nGrp, bInvertOrder, dStrand, vRibsPrintOrder) +local function ReorderRibs( nGrp, bInvertOrder, dStrand) local vIds = EgtGetNameInGroup( nGrp, RIBS_CRV .. '*') if not vIds or #vIds == 0 then return end @@ -1216,9 +1217,8 @@ local function ReorderRibs( nGrp, bInvertOrder, dStrand, vRibsPrintOrder) end -- riordino ogni tipologia - for i = 1, #vRibsPrintOrder do - local nCurrType = vRibsPrintOrder[i] - local vIds = tRibs[nCurrType] + for j = 1, 4 do + local vIds = tRibs[j] -- raggruppo in base allo split order local tSplitOrder = {} @@ -1292,7 +1292,7 @@ end --------------------------------------------------------------------------------------------- -- Funzione che riordina le costolature nel caso di intersezioni e 2 passate -local function ReorderRibsInters2Shells( nOffsGrp, dStrand, vRibsPrintOrder, bInvertOrder) +local function ReorderRibsInters2Shells( nOffsGrp, dStrand, bInvertOrder) local vOffs = {} local vClosed = {} @@ -1433,30 +1433,17 @@ local function ReorderRibsInters2Shells( nOffsGrp, dStrand, vRibsPrintOrder, bIn end end end - - -- classifico in base alla tipologia - local vCrvs = EgtGetNameInGroup( nOffsGrp, RIBS_CRV .. '*') - local tRibs = {{}, {}, {}, {}} - for nId = 1, #vCrvs do - local nType = EgtGetInfo( vCrvs[nId], KEY_RIBS_TYPE, 'i') - table.insert( tRibs[nType], vCrvs[nId]) - end - - -- riordino per tipologia - for i = 1, #vRibsPrintOrder do - nCurrType = vRibsPrintOrder[i] - local nStart = EgtIf( bInvertOrder, #tRibs[nCurrType], 1) - local nEnd = EgtIf( bInvertOrder, 1, #tRibs[nCurrType]) - local nStep = EgtIf( bInvertOrder, -1, 1) - for j = nStart, nEnd, nStep do - if bInvertOrder then - -- inverto curve per mantenere concatenamento - EgtInvertCurve( tRibs[nCurrType][j]) - end - EgtRelocateGlob( tRibs[nCurrType][j], nOffsGrp, GDB_IN.LAST_SON) + + -- eventuale inversione ordinamento + if bInvertOrder then + local vRibs = EgtGetNameInGroup( nOffsGrp, RIBS_CRV .. '*') + for j = #vRibs, 1, -1 do + -- inverto direzione curve per mantenere concatenamento + EgtInvertCurve( vRibs[j]) + EgtRelocateGlob( vRibs[j], nOffsGrp, GDB_IN.LAST_SON) end end - + end ------------------------------------------------------------------- @@ -1464,8 +1451,16 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, vPtStart) -- stabilisco ordine di realizzazione delle varie tipologie local vTypeSequence = {} - for i = 1, #LayerParams.vRibsPrintOrder do - vTypeSequence[LayerParams.vRibsPrintOrder[i]] = i + for i = 1, #LayerParams.vPrintOrder do + if LayerParams.vPrintOrder[i] == PRINT_ELEMENT.RIB_UNBOUNDED then + vTypeSequence[RIB_TYPE.UNBOUNDED] = i + elseif LayerParams.vPrintOrder[i] == PRINT_ELEMENT.RIB_INTERNAL then + vTypeSequence[RIB_TYPE.INTERNAL] = i + elseif LayerParams.vPrintOrder[i] == PRINT_ELEMENT.RIB_EXTERNAL then + vTypeSequence[RIB_TYPE.EXTERNAL] = i + elseif LayerParams.vPrintOrder[i] == PRINT_ELEMENT.RIB_SUPPORT then + vTypeSequence[RIB_TYPE.SUPPORT] = i + end end local vOrigRibs = EgtGetNameInGroup( nRibsGrp, RIBS_CRV .. '*') @@ -1591,15 +1586,25 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nIdx, vPtStart) -- riordino le costolature if bSpecialCase then -- gestione caso speciale di intersezione e 2 passate - ReorderRibsInters2Shells( nRibsPathGrp, LayerParams.dStrand, LayerParams.vRibsPrintOrder, LayerParams.bRibsInvertOrder) + ReorderRibsInters2Shells( nRibsPathGrp, LayerParams.dStrand, LayerParams.bRibsInvertOrder) else - ReorderRibs( nRibsPathGrp, LayerParams.bRibsInvertOrder, LayerParams.dStrand, LayerParams.vRibsPrintOrder) + ReorderRibs( nRibsPathGrp, LayerParams.bRibsInvertOrder, LayerParams.dStrand) end if not EgtGetFirstNameInGroup( nRibsPathGrp, RIBS_CRV .. '*') then EgtErase( nRibsPathGrp) end + -- sistemo le quote delle superfici e dei loop per CalcToolPath + local vLoopIds = EgtGetAllInGroup( nLoopGrp) or {} + for i = 1, #vLoopIds do + EgtMove( vLoopIds[i], LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) + end + local vSrfIds = EgtGetNameInGroup( nRibsPathGrp, TOT_SHELL_TRIM_SURF) or {} + for i = 1, #vSrfIds do + EgtMove( vSrfIds[i], LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) + end + nCrvGrp = EgtGetNextName( nCrvGrp, CONTOUR_GRP .. '*') end end @@ -2128,7 +2133,7 @@ function CalcPaths.Exec( nPartId) s_nPartId = nPartId - local vLayIds = EgtGetNameInGroup( s_nPartId, SLICE_LAYER.."*") + local vLayIds = EgtGetNameInGroup( s_nPartId, SLICE_LAYER.."*") if not vLayIds then EgtOutBox( 'Error no slice', 'PathCalc') return @@ -2269,7 +2274,7 @@ function CalcPaths.Exec( nPartId) if EgtProcessEvents( EgtIf( PRINT, 200, 0) + nIdx / #vLayIds * 100, 0) == 1 then EgtDraw() - return + return end end end diff --git a/LuaLibs/CalcToolPath.lua b/LuaLibs/CalcToolPath.lua index 15811ae..92b0367 100644 --- a/LuaLibs/CalcToolPath.lua +++ b/LuaLibs/CalcToolPath.lua @@ -26,7 +26,7 @@ local function GetLayerParamsForToolPathCalc() LayerParams.dOffs = EgtGetInfo( s_nPartId, KEY_OFFSET_SLICE, 'd') LayerParams.bInvert = ( EgtGetInfo( s_nPartId, KEY_PRINT_DIRECTION, 'i') == PRINT_DIRECTION.CW) LayerParams.nOrder = EgtGetInfo( s_nPartId, KEY_STRAND_ORDER, 'i') - LayerParams.vPrintOrder = EgtGetInfo( s_nPartId, KEY_PRINT_ORDER, 'vi') or { 1, 2, 3, 4, 5} + LayerParams.vPrintOrder = EgtGetInfo( s_nPartId, KEY_PRINT_ORDER, 'vi') or { 1, 2, 3, 4, 5, 6, 7, 8} LayerParams.nLinkType = EgtGetInfo( s_nPartId, KEY_LINK_TYPE, 'i') LayerParams.dLinkParam = EgtGetInfo( s_nPartId, KEY_LINK_PARAM, 'd') LayerParams.nLeadInType = EgtGetInfo( s_nPartId, KEY_LEAD_IN_TYPE, 'i') @@ -671,7 +671,7 @@ local function CalcRibsLink( nCurr, nNext, nLoopGrp, dStrand, bForceLink, vtSlic return nLinkId end - nCrvId = EgtGetNextName( nCrvId, TRIM_SURF_LOOP) + nCrvId = EgtGetNextName( nCrvId, TRIM_SURF_LOOP) end -- se non ho trovato un collegamento sul bordo, creo una linea tra ptS e ptE @@ -989,16 +989,16 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, vtSlicing, dStrand, n end --------------------------------------------------------------------- -local function CalcRibsToolPath( nRibsGrp, nTpathGrpId, LayerParams) +local function CalcRibsToolPath( vEntIds, nRibsGrp, nTpathGrpId, LayerParams) - if not nRibsGrp then return end + if not vEntIds or #vEntIds == 0 then return end -- gruppo temporaneo con sistema di riferimento locale per conti local frLoc = Frame3d( ORIG(), LayerParams.vtSlicing) local nGrpTmp = EgtGroup( nRibsGrp, frLoc, GDB_RT.GLOB) -- aggiungo le costolature nel toolpath - local vEntIds = EgtGetNameInGroup( nRibsGrp, RIBS_CRV .. '*') + local nNewFirstEnt for i = 1, #vEntIds do -- copio entità nel gruppo toolpath local nNewEntId = EgtCopyGlob( vEntIds[i], nTpathGrpId, GDB_IN.LAST_SON) @@ -1006,24 +1006,12 @@ local function CalcRibsToolPath( nRibsGrp, nTpathGrpId, LayerParams) EgtMove( nNewEntId, LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) EgtModifyCurveExtrusion( nNewEntId, LayerParams.vtSlicing, GDB_RT.GLOB) EgtSetColor( nNewEntId, EgtStdColor('MAROON')) - end - - -- posiziono alla quota corretta i loop degli offset da utlizzare per link, ingressi e uscite - local nLoopGrp = EgtGetFirstGroupInGroup( nRibsGrp) - local vLoopIds = EgtGetAllInGroup( nLoopGrp) - for i = 1, #vLoopIds do - EgtMove( vLoopIds[i], LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) + if i == 1 then nNewFirstEnt = nNewEntId end end - -- posizono alla quota corretta le superfici usate per i trim - local vSrfIds = EgtGetNameInGroup( nRibsGrp, TOT_SHELL_TRIM_SURF) or {} - for i = 1, #vSrfIds do - EgtMove( vSrfIds[i], LayerParams.dLayHeight * LayerParams.vtSlicing, GDB_RT.GLOB) - end - -- recupero i gruppi delle costolature local tabRibs = {} - local nFirst = EgtGetFirstNameInGroup( nTpathGrpId, RIBS_CRV .. '*') + local nFirst = nNewFirstEnt while nFirst do local sName = EgtGetName( nFirst) local vIds = EgtGetNameInGroup( nTpathGrpId, sName) @@ -1034,23 +1022,27 @@ local function CalcRibsToolPath( nRibsGrp, nTpathGrpId, LayerParams) local bSpecialCase = EgtGetInfo( nRibsGrp, KEY_RIBS_SPECIAL_CASE, 'b') or false -- Link + local nLoopGrp = EgtGetFirstGroupInGroup( nRibsGrp) -- collego le passate di una stessa costolatura for i = 1, #tabRibs do if EgtCurveIsClosed( tabRibs[i][1]) then AddLink( tabRibs[i], nTpathGrpId, LINK_TYPE.NONE, LayerParams.dLinkParam, LayerParams.dSPOffs, LayerParams.dStrand, LayerParams.vtSlicing) else for j = 1, #tabRibs[i] - 1 do - local nOrig1 = EgtGetInfo( tabRibs[i][j], KEY_ORIGINAL_RIB, 'i') - local nOrig2 = EgtGetInfo( tabRibs[i][j + 1], KEY_ORIGINAL_RIB, 'i') + local bUserLink = EgtGetInfo( tabRibs[i][j], 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 and nSplitId1 == nSplitId2) + local bForceLink = ( nOrig1 == nOrig2) - 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) + if ( nOrig1 ~= nOrig2 and bUserLink) or ( nSplitId1 == nSplitId2 and nOrig1 == nOrig2) then + 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 end end @@ -1071,16 +1063,14 @@ local function CalcRibsToolPath( nRibsGrp, nTpathGrpId, LayerParams) for i = 1, #tabRibs - 1 do local bLink1 = EgtGetInfo( tabRibs[i][1], KEY_RIBS_LINK, 'b') local bLink2 = EgtGetInfo( tabRibs[i + 1][1], KEY_RIBS_LINK, 'b') - local nType1 = EgtGetInfo( tabRibs[i][1], KEY_RIBS_TYPE, 'i') - local nType2 = EgtGetInfo( tabRibs[i + 1][1], KEY_RIBS_TYPE, 'i') - if bLink1 and bLink2 and nType1 == nType2 then + if bLink1 and bLink2 then local nCnt = #tabRibs[i] CalcRibsLink( tabRibs[i][nCnt], tabRibs[i + 1][1], nLoopGrp, LayerParams.dStrand, false, LayerParams.vtSlicing, nGrpTmp) end end -- leadin/leadout - local nCrvRib = EgtGetFirstNameInGroup( nTpathGrpId, RIBS_CRV .. '*') + local nCrvRib = nNewFirstEnt while nCrvRib do -- verifico se necessario lead in local nPrev = EgtGetPrev( nCrvRib) @@ -1251,13 +1241,13 @@ end function CalcToolPath.Exec( nPartId) s_nPartId = nPartId - + -- Verifico il pezzo if not s_nPartId then EgtOutBox( 'Error missing part', 'ToolPathCalc') return end - + -- Recupero i layer da processare local vLayIds = EgtGetNameInGroup( s_nPartId, SLICE_LAYER.."*") if not vLayIds then @@ -1303,6 +1293,15 @@ function CalcToolPath.Exec( nPartId) EgtEmptyGroup( nTpathGrpId) end + -- suddivido i ribs per tipologia + local nRibsGrp = EgtGetFirstNameInGroup( nCrvGrpId, RIBS_GRP) + local tRibs = {{}, {}, {}, {}} + local vRibsIds = EgtGetNameInGroup( nRibsGrp, RIBS_CRV .. '*') or {} + for i = 1, #vRibsIds do + local nType = EgtGetInfo( vRibsIds[i], KEY_RIBS_TYPE, 'i') or 1 + table.insert( tRibs[nType], vRibsIds[i]) + end + -- realizzo le diverse tipologie in base all'ordine selezionato for j = 1, #LayerParams.vPrintOrder do @@ -1323,10 +1322,16 @@ function CalcToolPath.Exec( nPartId) local nAuxSolidsGrp = EgtGetFirstNameInGroup( vLayIds[nIdx], AUX_SOLIDS_GRP) local nAuxSolidsPathGrp = EgtGetFirstNameInGroup( nCrvGrpId, AUX_SOLIDS_GRP) CalcAuxSolidsToolPath( nAuxSolidsGrp, nAuxSolidsPathGrp, nTpathGrpId, LayerParams) - else + -- costolature - local nRibsGrp = EgtGetFirstNameInGroup( nCrvGrpId, RIBS_GRP) - CalcRibsToolPath( nRibsGrp, nTpathGrpId, LayerParams) + elseif LayerParams.vPrintOrder[j] == PRINT_ELEMENT.RIB_UNBOUNDED then + CalcRibsToolPath( tRibs[RIB_TYPE.UNBOUNDED], nRibsGrp, nTpathGrpId, LayerParams) + elseif LayerParams.vPrintOrder[j] == PRINT_ELEMENT.RIB_INTERNAL then + CalcRibsToolPath( tRibs[RIB_TYPE.INTERNAL], nRibsGrp, nTpathGrpId, LayerParams) + elseif LayerParams.vPrintOrder[j] == PRINT_ELEMENT.RIB_SUPPORT then + CalcRibsToolPath( tRibs[RIB_TYPE.SUPPORT], nRibsGrp, nTpathGrpId, LayerParams) + elseif LayerParams.vPrintOrder[j] == PRINT_ELEMENT.RIB_EXTERNAL then + CalcRibsToolPath( tRibs[RIB_TYPE.EXTERNAL], nRibsGrp, nTpathGrpId, LayerParams) end end diff --git a/LuaLibs/RunSlicing.lua b/LuaLibs/RunSlicing.lua index 161ebfd..db5cb21 100644 --- a/LuaLibs/RunSlicing.lua +++ b/LuaLibs/RunSlicing.lua @@ -55,7 +55,7 @@ local function LoadParams( sFile, nPartId) SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_SHELLS_NBR, '3') SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_STRAND_OVERLAP, '0') SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_OFFSET_SLICE, '0.0') - SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_PRINT_ORDER, '1,2,3,4,5') + SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_PRINT_ORDER, '1,2,3,4,5,6,7,8') local sStrandOrder = EgtGetStringFromIni( SEC_DEFAULT, KEY_STRAND_ORDER, 'InToOut', sFile) if sStrandOrder == 'OutToIn' then @@ -152,7 +152,6 @@ local function LoadParams( sFile, nPartId) end SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_OVERLAP, '0.0') - SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_PRINT_ORDER, '3,1,4,2') SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_SHELLS_NBR, '0') SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_INVERT_DIR, '0') SetParamInfo( sFile, nPartId, SEC_DEFAULT, KEY_RIBS_INVERT_STRAND_ORDER, '0')