diff --git a/LuaLibs/AddManData.lua b/LuaLibs/AddManData.lua index 85f7dbf..d105312 100644 --- a/LuaLibs/AddManData.lua +++ b/LuaLibs/AddManData.lua @@ -80,6 +80,7 @@ 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_INTERS = "RibsHaveIntersections" -- Parametri di macchina SEC_3DPRINTING = "3dPrinting" diff --git a/LuaLibs/CalcPaths.lua b/LuaLibs/CalcPaths.lua index 1a82df5..2669e72 100644 --- a/LuaLibs/CalcPaths.lua +++ b/LuaLibs/CalcPaths.lua @@ -72,7 +72,7 @@ local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, nLayId) end -- scelta start point - local ptStart = GetLayerStartPoint( nLayId) + local ptStart = GetLayerStartPoint( nLayId) EgtChangeClosedCurveStartPoint( nCrvId + nInd, ptStart, GDB_RT.GLOB) end end @@ -102,6 +102,195 @@ local function AddFloor( nSrfId, nGrpId, LayerParams, nFloorNbr) end -------------------------------------------------------------------- +local function TrimRibsOffset( nCrv, nOffs1, nOffs2, nOffsGrp, bIn) + + local ptInt1 = EgtIP( nCrv, nOffs1, ORIG()) + local ptInt2 = EgtIP( nCrv, nOffs2, ORIG()) + local dPar1, dPar2 + if ptInt1 then dPar1 = EgtCurveParamAtPoint( nCrv, ptInt1) end + if ptInt2 then dPar2 = EgtCurveParamAtPoint( nCrv, ptInt2) end + + if dPar1 and dPar2 then + -- la curva viene spezzata in tre parti + if dPar1 > dPar2 then + dPar1, dPar2 = dPar2, dPar1 + end + local nCopy = EgtCopyGlob( nCrv, nOffsGrp) + EgtTrimCurveEndAtParam( EgtIf( bIn, nCrv, nCopy), dPar1) + EgtTrimCurveStartAtParam( EgtIf( bIn, nCopy, nCrv), dPar2) + + elseif dPar1 or dPar2 then + if bIn then + EgtTrimCurveEndAtParam( nCrv, dPar1 or dPar2) + else + EgtTrimCurveStartAtParam( nCrv, dPar1 or dPar2) + end + end +end + +-------------------------------------------------------------------- +-- Funzione che sistema le intersezioni fra costolature nel caso generico +local function AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nOffsGrp, bIn) + + -- calcolo gli offset della curva principale ( nCrv1) da usare per trim + local dOffs = ( LayerParams.nRibsShellsNbr - 1) * LayerParams.dStrand / 2 + local nOffsM = EgtOffsetCurveAdv( nCrv1, - dOffs - ( 1 - LayerParams.dRibsOverlap / 100) * LayerParams.dStrand) + local nOffsP = EgtOffsetCurveAdv( nCrv1, dOffs + ( 1 - LayerParams.dRibsOverlap / 100) * LayerParams.dStrand) + local vSplit = {} + + -- recupero gli offset della curva secondaria ( nCrv2) + local vOffs2 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv2)) + -- trim degli offset della curva secondaria + for i = 1, #vOffs2 do + TrimRibsOffset( vOffs2[i], nOffsM, nOffsP, nOffsGrp, bIn) + end + + EgtErase( nOffsM) + EgtErase( nOffsP) +end + +-------------------------------------------------------------------- +-- Funzione che sistema le intersezioni fra costolature nel caso di 2 passate +local function AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nOffsGrp, bIn) + + -- recupero gli offset delle due curve + local vOffs1 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv1)) + local vOffs2 = EgtGetNameInGroup( nOffsGrp, EgtGetName( nCrv2)) + + local vCopy1 = {} + for i = 1, #vOffs1 do + local nId = EgtCopyGlob( vOffs1[i], nOffsGrp) + table.insert( vCopy1, nId) + end + + -- trim degli offset di nCrv1 + for i = 1, #vOffs1 do + -- trovo gli offset di nCrv2 coinvolti nell'intersezione + local vIds = {} + for j = 1, #vOffs2 do + local ptInt = EgtIP( vOffs1[i], vOffs2[j], ORIG()) + if ptInt then table.insert( vIds, j) end + end + if #vIds > 0 then + local bInCrv1 = false + -- se viene trovata una sola intersezione devo calcolare bIn per nCrv1 + if #vIds == 1 then + table.insert( vIds, EgtIf( vIds[1] == 1, 2, 1)) + local ptInt = EgtIP( nCrv1, nCrv2, ORIG()) + local dParInt = EgtCurveParamAtPoint( nCrv1, ptInt) + local _, dParE = EgtCurveDomain( nCrv1) + bInCrv1 = abs( dParInt - dParE) < 100 * GEO.EPS_SMALL + end + TrimRibsOffset( vOffs1[i], vOffs2[vIds[1]], vOffs2[vIds[2]], nOffsGrp, bInCrv1) + end + + end + -- trim degli offset di nCrv2 + for i = 1, #vOffs2 do + -- trovo gli offset di nCrv1 coinvolti nell'intersezione + local vIds = {} + for j = 1, #vCopy1 do + local ptInt = EgtIP( vOffs2[i], vCopy1[j], ORIG()) + if ptInt then table.insert( vIds, j) end + end + if #vIds > 0 then + if #vIds == 1 then table.insert( vIds, EgtIf( vIds[1] == 1, 2, 1)) end + TrimRibsOffset( vOffs2[i], vCopy1[vIds[1]], vCopy1[vIds[2]], nOffsGrp, bIn) + end + end + + for i = 1, #vCopy1 do + EgtErase( vCopy1[i]) + end + +end + +-------------------------------------------------------------------- +local function HandleRibsIntersections( nRibsGrp, LayerParams, nOffsGrp, nRibsPathGrp) + + local nCrvGrp = EgtGetParent( nRibsPathGrp) + local nSrf = EgtGetFirstInGroup( nCrvGrp) + + local vRibsIds = {} + local vOrigRibs = EgtGetNameInGroup( nRibsGrp, RIBS_CRV .. '*') + local nTrimmedRibsGrp = EgtGroup( nRibsPathGrp) + for i = 1, #vOrigRibs do + local nCopyId = EgtCopyGlob( vOrigRibs[i], nTrimmedRibsGrp) + local nCrv, nCnt = EgtTrimCurveWithRegion( nCopyId, nSrf, true, false) + for j = nCrv, nCrv + nCnt - 1 do + table.insert( vRibsIds, j) + end + -- copio i suoi offset nel RibsPathGrp + local vOffsRib = EgtGetNameInGroup( nOffsGrp, EgtGetName( vOrigRibs[i])) + for i = 1, #vOffsRib do + EgtCopyGlob( vOffsRib[i], nRibsPathGrp) + end + end + + local bInters = false + local vSplit = {} + for i = 1, #vRibsIds do + -- verifico se interseca uno dei setti successivi + for j = i + 1, #vRibsIds do + local ptInt = EgtIP( vRibsIds[i], vRibsIds[j], ORIG()) + if ptInt then + bInters = true + + local dPar1 = EgtCurveParamAtPoint( vRibsIds[i], ptInt) + local dPar2 = EgtCurveParamAtPoint( vRibsIds[j], ptInt) + local _, dParE1 = EgtCurveDomain( vRibsIds[i]) + local _, dParE2 = EgtCurveDomain( vRibsIds[j]) + + local bIn = abs( dPar1 - dParE1) < 50 * GEO.EPS_SMALL or abs( dPar2 - dParE2) < 50 * GEO.EPS_SMALL + local nCrv1 = vRibsIds[i] -- curva principale che non viene tagliata + local nCrv2 = vRibsIds[j] -- curve secondaria da modificare + if dPar1 < 50 * GEO.EPS_SMALL or abs( dPar1 - dParE1) < 50 * GEO.EPS_SMALL then + nCrv1, nCrv2 = nCrv2, nCrv1 + end + + if LayerParams.nRibsShellsNbr == 2 then + -- nel caso di 2 passate gestione speciale + AdjustRibsOffsetForIntersection2Shells( nCrv1, nCrv2, LayerParams, nRibsPathGrp, bIn) + else + AdjustRibsOffsetForIntersection( nCrv1, nCrv2, LayerParams, nRibsPathGrp, bIn) + end + end + end + end + + EgtErase( nTrimmedRibsGrp) + + -- nel caso di intersezione sistemo i nomi in modo da gestire separatamente le costolature divise + if bInters then + local vRibsNames = {} + for i = 1, #vOrigRibs do + local sName = EgtGetName( vOrigRibs[i]) + table.insert( vRibsNames, sName) + end + local kMax = tonumber( string.sub( vRibsNames[#vRibsNames], 4)) + 1 + + for i = 1, #vRibsNames do + local vIds = EgtGetNameInGroup( nRibsPathGrp, vRibsNames[i]) + for j = 2, #vIds do + local ptM = EgtMP( vIds[j]) + local dDist = EgtPointCurveDist( ptM, vIds[j-1]) + if abs( dDist - LayerParams.dStrand) < 10 * GEO.EPS_SMALL then + -- se le costolatura è vicina alla precedente avrà lo stesso nome + EgtSetName( vIds[j], EgtGetName( vIds[j-1])) + else + -- se la costolatura dista troppo dalla precedente le cambio il nome + EgtSetName( vIds[j], RIBS_CRV .. tostring( kMax)) + kMax = kMax + 1 + end + end + end + end + + return bInters +end + +-------------------------------------------------------------------- +-- Funzione che riordina le costolature nel caso generico local function ReorderRibs( nGrp, bInvertOrder) EgtSpInit() @@ -113,18 +302,75 @@ local function ReorderRibs( nGrp, bInvertOrder) local vOrd, dLen = EgtSpCalculate( SHP_TY.OPEN) EgtSpTerminate() - local vOrderedRibs = {} - if bInvertOrder then - for i = #vOrd, 1, -1 do - table.insert( vOrderedRibs, vIds[vOrd[i]]) - end - else - for i = 1, #vOrd do - table.insert( vOrderedRibs, vIds[vOrd[i]]) + EgtRelocateGlob( vIds[vOrd[1]], nGrp, EgtIf( bInvertOrder, GDB_IN.LAST, GDB_IN.FIRST)) + for i = 2, #vOrd do + EgtRelocateGlob( vIds[vOrd[i]], vIds[vOrd[i-1]], EgtIf( bInvertOrder, GDB_IN.BEFORE, GDB_IN.AFTER)) + end +end + +--------------------------------------------------------------------------------------------- +-- Funzione che riordina le costolature nel caso di intersezioni e 2 passate +local function ReorderRibsInters2Shells( nOffsGrp, dStrand) + + local vOffs = EgtGetNameInGroup( nOffsGrp, RIBS_CRV .. '*') + -- concateno le curve + local nCrv, nCnt = EgtCurveCompoByChain( nOffsGrp, vOffs, ORIG()) + + local vIds = {} + for i = nCrv, nCrv + nCnt - 1 do + EgtSetInfo( i, KEY_TYPE, TYPE.RIB) + table.insert( vIds, i) + end + + local k = 0 -- indice da utilizzare per i nomi + while #vIds > 0 do + k = k + 1 + -- prendo la prima tra le curve a disposizione + nCurrCrv = vIds[1] + table.remove( vIds, 1) + EgtSetName( nCurrCrv, RIBS_CRV .. tostring(k)) + local pt = EgtEP( nCurrCrv) + local nCnt = 0 + -- scorro alla ricerca di una curva che posso collegare alla corrente + while nCurrCrv do + local bFound = false + for j = 1, #vIds do + if vIds[j] ~= nCrv then + local ptS = EgtSP( vIds[j]) + local ptE = EgtEP( vIds[j]) + + local bAddNoInvert = dist( pt, ptS) < dStrand + 10 * GEO.EPS_SMALL + local bAddWithInvert = dist( pt, ptE) < dStrand + 10 * GEO.EPS_SMALL + if bAddNoInvert or bAddWithInvert then + bFound = true + nCnt = nCnt + 1 + EgtRelocateGlob( vIds[j], nCurrCrv, GDB_IN.AFTER) + EgtSetName( vIds[j], RIBS_CRV .. tostring( k)) + -- eventuale inversione della curva + if bAddWithInvert then EgtInvertCurve( vIds[j]) end + + -- aggiorno per collegamento successivo + pt = EgtIf( bAddNoInvert, ptE, ptS) + nCurrCrv = vIds[j] + -- elimino la curva dal vettore di curve da considerare + table.remove( vIds, j) + break + end + end + end + -- se non ho più curve da collegare + if not bFound then + -- se il percorso è fatto da una sola curva, riprovo a cercare collegamenti invertendola + if nCnt == 0 then + EgtInvertCurve( nCurrCrv) + pt = EgtEP( nCurrCrv) + nCnt = 1 -- per evitare di finire in un loop + else + nCurrCrv = nil + end + end end end - - return vOrderedRibs end -------------------------------------------------------------------- @@ -141,24 +387,34 @@ local function CalcRibsPaths( nSliceGrp, nRibsGrp, LayerParams, nStmId) EgtSetInfo( nNewId, KEY_TYPE, TYPE.RIB) EgtRelocateGlob( nNewId, nOffsGrp) end - end - - -- riordino costolature - local vOrderedRibs = ReorderRibs( nOffsGrp, LayerParams.bRibsInvertOrder) + end + -- scorro i gruppi di curve local nCrvGrp = EgtGetFirstNameInGroup( nSliceGrp, CONTOUR_GRP .. '*') while nCrvGrp do local nRibsPathGrp = EgtGetFirstNameInGroup( nCrvGrp, RIBS_GRP) local nSrf = EgtGetFirstNameInGroup( nRibsPathGrp, LAYER_SRF) - if nSrf then - for i = 1, #vOrderedRibs do - local nNewId = EgtCopyGlob( vOrderedRibs[i], nRibsPathGrp) - -- trim delle costole con la regione offsettata - local nCrv, nCnt = EgtTrimCurveWithRegion( nNewId, nSrf, true, false) + if nSrf then + -- gestisco eventuali intersezioni fra costolature + local bInters = HandleRibsIntersections( nRibsGrp, LayerParams, nOffsGrp, nRibsPathGrp) + EgtSetInfo( nRibsPathGrp or GDB_ID.NULL, KEY_RIBS_INTERS, bInters) + + -- riordino le costolature + if LayerParams.nRibsShellsNbr == 2 and bInters then + -- gestione caso speciale di intersezione e 2 passate + ReorderRibsInters2Shells( nRibsPathGrp, LayerParams.dStrand) + else + ReorderRibs( nRibsPathGrp, LayerParams.bRibsInvertOrder) + end + + -- eseguo il trim delle costole con la regione offsettata + local vOrderedRibs = EgtGetNameInGroup( nRibsPathGrp, RIBS_CRV .. '*') + for i = 1, #vOrderedRibs do + local nCrv, nCnt = EgtTrimCurveWithRegion( vOrderedRibs[i], nSrf, true, false) -- elimino tratti troppo corti for nId = nCrv, nCrv + nCnt - 1 do local dLen = EgtCurveLength( nId) - if dLen < MIN_LEN then + if dLen < 10 * MIN_LEN then EgtErase( nId) end end @@ -214,18 +470,22 @@ function CalcPaths.Exec( nPartId, nStmId) -- esterno local nSrfId = EgtCopyGlob( nSrf, nCrvGrpId) local dOffs = 0.5 * LayerParams.dStrand - LayerParams.dOffs - local bOk = ( EgtSurfFrOffset( nSrfId, -dOffs) and EgtSurfFrChunkCount( nSrfId) > 0) + local bOk = EgtSurfFrOffset( nSrfId, -dOffs) + local bExists = EgtSurfFrChunkCount( nSrfId) > 0 if not bOk then EgtErase( nSrfId) nSrfId = EgtCopyGlob( nSrf, nCrvGrpId) local dNewOffs = dOffs - 0.05 - bOk = ( EgtSurfFrOffset( nSrfId, -dNewOffs) and EgtSurfFrChunkCount( nSrfId) > 0) + bOk = EgtSurfFrOffset( nSrfId, -dNewOffs) + bExists = EgtSurfFrChunkCount( nSrfId) > 0 end -- se offset riuscito, estraggo i contorni (pareti esterne) - if bOk then - GetPathsFromSurf( nSrfId, SHELL_CRV..'0', TYPE.OUTER_SHELL, nGrpId, vLayIds[nIdx]) - else + if not bOk then EgtOutLog( 'Error on ExtOffset (layer '..tostring( nIdx)..') - CalcPaths') + elseif not bExists then + EgtOutLog( 'Warning : ExtOffset not possible (layer '..tostring( nIdx)..') - CalcPaths') + else + GetPathsFromSurf( nSrfId, SHELL_CRV..'0', TYPE.OUTER_SHELL, nGrpId, vLayIds[nIdx]) end EgtErase( nSrfId) @@ -233,17 +493,21 @@ function CalcPaths.Exec( nPartId, nStmId) for nInd2 = 1, LayerParams.nShellsNbr - 1 do -- offset della superficie originale local nSrfId = EgtCopy( nSrf, nGrpId) - local bOk = ( EgtSurfFrOffset( nSrfId, - dOffs - nInd2 * LayerParams.dStrand) and EgtSurfFrChunkCount( nSrfId) > 0) + local bOk = EgtSurfFrOffset( nSrfId, - dOffs - nInd2 * LayerParams.dStrand) + local bExists = EgtSurfFrChunkCount( nSrfId) > 0 if not bOk then EgtErase( nSrfId) nSrfId = EgtCopyGlob( nSrf, nCrvGrpId) - bOk = ( EgtSurfFrOffset( nSrfId, -dOffs + 0.05 - nInd2 * LayerParams.dStrand) and EgtSurfFrChunkCount( nSrfId) > 0) + bOk = EgtSurfFrOffset( nSrfId, -dOffs + 0.05 - nInd2 * LayerParams.dStrand) + bExists = EgtSurfFrChunkCount( nSrfId) > 0 end -- se offset riuscito, estraggo i contorni ( pareti interne) - if bOk then - GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, vLayIds[nIdx]) - else + if not bOk then EgtOutLog( 'Error on IntOffset (layer '..tostring( nIdx)..') - CalcPaths') + elseif not bExists then + EgtOutLog( 'Warning : IntOffset not possible (layer '..tostring( nIdx)..') - CalcPaths') + else + GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, vLayIds[nIdx]) end EgtErase( nSrfId) end diff --git a/LuaLibs/CalcSolids.lua b/LuaLibs/CalcSolids.lua index 03fecc4..a9dcd34 100644 --- a/LuaLibs/CalcSolids.lua +++ b/LuaLibs/CalcSolids.lua @@ -160,8 +160,12 @@ local function CreateSolidFromCurve( nCrvId, nSolidGrp, LayerParams) nSrfId = CreateSolid( nGuideId, nSolidGrp, LayerParams.dStrand + 100 * GEO.EPS_SMALL, LayerParams.dLayHeight, LayerParams.vtSlicing) if not nSrfId then -- ritento spezzando la curva - local nFirstCrv, nCrvNbr = EgtSplitCurveAtCorners( nGuideId, 60) - if nFirstCrv then + local nGrp = EgtGroup( nSolidGrp, Frame3d( ORIG(), LayerParams.vtSlicing)) + EgtRelocateGlob( nGuideId, nGrp) + EgtApproxCurve( nGuideId, GDB_CA.LINES, 100 * GEO.EPS_SMALL) + EgtRelocateGlob( nGuideId, nSolidGrp) + local nFirstCrv, nCrvNbr = EgtSplitCurveAtCorners( nGuideId, 30) + if nFirstCrv and nCrvNbr > 1 then local nSrfIds = {} for nInd2 = 0, nCrvNbr-1 do local nSrfId2 = CreateSolid( nFirstCrv + nInd2, nSolidGrp, LayerParams.dStrand - 100 * GEO.EPS_SMALL, LayerParams.dLayHeight, LayerParams.vtSlicing) diff --git a/LuaLibs/CalcToolPath.lua b/LuaLibs/CalcToolPath.lua index 2d55e14..47cfe70 100644 --- a/LuaLibs/CalcToolPath.lua +++ b/LuaLibs/CalcToolPath.lua @@ -265,9 +265,19 @@ local function AddRibsLeadIn( nCrv, nLoopsGrp, LayerParams) if abs( dParS - dEndPar) < GEO.EPS_SMALL then EgtInvertCurve( nCrvId) elseif abs( dParS) > GEO.EPS_SMALL or bClosed then - -- se ho più tratti possibili scelgo in base al parametro RibsLIInvert + -- se ho più tratti possibili scelgo in base al parametro RibsLIInvert o alle dimensioni local nNewId = EgtSplitCurveAtParam( nCrvId, dParS) or EgtCopyGlob( nCrvId, nCrv, GDB_IN.BEFORE) - if LayerParams.bRibsLIInvert then + local dLen1 = EgtCurveLength( nCrvId) + local dLen2 = EgtCurveLength( nNewId) + + local bKeepFirst = LayerParams.bRibsLIInvert + if dLen1 > LayerParams.dRibsLILen - GEO.EPS_SMALL and dLen2 < LayerParams.dRibsLILen - GEO.EPS_SMALL then + bKeepFirst = true + elseif dLen1 < LayerParams.dRibsLILen - GEO.EPS_SMALL and dLen2 > LayerParams.dRibsLILen - GEO.EPS_SMALL then + bKeepFirst = false + end + + if bKeepFirst then EgtInvertCurve( nCrvId) EgtErase( nNewId) else @@ -320,9 +330,17 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, LayerParams) EgtInvertCurve( nCrvRef) bInvert = true elseif abs( dParE) > GEO.EPS_SMALL or bClosed then - -- se ho più tratti possibili scelgo in base al parametro RibsLOInvert - bInvert = LayerParams.bRibsLOInvert + -- se ho più tratti possibili scelgo in base al parametro RibsLOInvert o alle dimensioni local nNewId = EgtSplitCurveAtParam( nCrvRef, dParE) or EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER) + local dLen1 = EgtCurveLength( nCrvRef) + local dLen2 = EgtCurveLength( nNewId) + bInvert = LayerParams.bRibsLOInvert + if dLen1 > LayerParams.dRibsLOLen + LayerParams.dRibsLOCoasting - GEO.EPS_SMALL and dLen2 < LayerParams.dRibsLOLen + LayerParams.dRibsLOCoasting - GEO.EPS_SMALL then + bInvert = true + elseif dLen1 < LayerParams.dRibsLOLen + LayerParams.dRibsLOCoasting - GEO.EPS_SMALL and dLen2 > LayerParams.dRibsLOLen + LayerParams.dRibsLOCoasting - GEO.EPS_SMALL then + bInvert = false + end + if bInvert then EgtInvertCurve( nCrvRef) EgtErase( nNewId) @@ -332,10 +350,13 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, LayerParams) end end + -- verifico se la curva ha lunghezza sufficiente + local dLen = EgtCurveLength( nCrvRef) + local bSkip = ( dLen - LayerParams.dRibsLOLen - LayerParams.dRibsLOCoasting < - GEO.EPS_SMALL) local vtE = EgtSV( nCrvRef) -- primo tratto ( segue offset con flusso aperto) - if LayerParams.dRibsLOLen > GEO.EPS_SMALL then + if LayerParams.dRibsLOLen > GEO.EPS_SMALL and not bSkip then nCrvLO = EgtCopyGlob( nCrvRef, nCrv, GDB_IN.AFTER) EgtTrimCurveEndAtLen( nCrvLO, LayerParams.dRibsLOLen) EgtSetInfo( nCrvLO, KEY_TYPE, TYPE.RIB) @@ -346,9 +367,9 @@ local function AddRibsLeadOut( nCrv, nTPathGrp, nLoopsGrp, LayerParams) end -- secondo tratto ( segue offset con flusso chiuso) - if LayerParams.dRibsLOCoasting > GEO.EPS_SMALL then + if LayerParams.dRibsLOCoasting > GEO.EPS_SMALL and not bSkip then nCoasting = EgtCopyGlob( nCrvRef, nCrvLO or nCrv, GDB_IN.AFTER) - EgtTrimCurveStartAtLen( nCoasting, LayerParams.dRibsLOLen) + EgtTrimCurveStartAtLen( nCoasting, LayerParams.dRibsLOLen) EgtTrimCurveEndAtLen( nCoasting, LayerParams.dRibsLOCoasting) EgtSetName( nCoasting, COASTING_CRV) @@ -423,18 +444,22 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ) nFirst = EgtGetNextName( vIds[#vIds], RIBS_CRV .. '*') end + local bInters = EgtGetInfo( nRibsGrp, KEY_RIBS_INTERS, 'b') or false + local bSpecialCase = bInters and LayerParams.nRibsShellsNbr == 2 -- orientamento delle curve - local bInvert = LayerParams.bRibsInvert - for i = 1, #tabRibs do - -- oriento tutte le passate relative ad una stessa costolatura - for j = 1, #tabRibs[i] do - if ( bInvert and j % 2 == 1) or ( not bInvert and j % 2 == 0) then - EgtInvertCurve( tabRibs[i][j]) + local bInvert = LayerParams.bRibsInvert + if not bSpecialCase then + for i = 1, #tabRibs do + -- oriento tutte le passate relative ad una stessa costolatura + for j = 1, #tabRibs[i] do + if ( bInvert and j % 2 == 1) or ( not bInvert and j % 2 == 0) then + EgtInvertCurve( tabRibs[i][j]) + end + end + -- aggiorno bInvert per il gruppo di costolature successivo + if LayerParams.bRibsLink and LayerParams.nRibsShellsNbr % 2 == 1 then + bInvert = not bInvert end - end - -- aggiorno bInvert per il gruppo di costolature successivo - if LayerParams.bRibsLink and LayerParams.nRibsShellsNbr % 2 == 1 then - bInvert = not bInvert end end @@ -445,10 +470,16 @@ local function CalcRibsToolPath( nCrvGrp, nTpathGrpId, LayerParams, dCorrZ) local ptS = EgtEP( tabRibs[i][j]) local ptE = EgtSP( tabRibs[i][j + 1]) CalcRibsLink( ptS, ptE, tabRibs[i][j], nLoopGrp, true) - -- creo link fittizio per eliminare tratto corrispondente sulla curva di offset - local nFakeLink = CalcRibsLink( EgtSP( tabRibs[i][j]), EgtEP( tabRibs[i][j + 1]), tabRibs[i][j], nLoopGrp, false) - EgtErase( nFakeLink) + if not bSpecialCase then + -- creo link fittizio per eliminare tratto corrispondente sulla curva di offset + local nFakeLink = CalcRibsLink( EgtSP( tabRibs[i][j]), EgtEP( tabRibs[i][j + 1]), tabRibs[i][j], nLoopGrp, false) + EgtErase( nFakeLink) + end end + if bSpecialCase then + local nFakeLink = CalcRibsLink( EgtSP( tabRibs[i][1]), EgtEP( tabRibs[i][#tabRibs[i]]), tabRibs[i][1], nLoopGrp, false) + EgtErase( nFakeLink) + end end -- se necessario collego le diverse costolature if LayerParams.bRibsLink then