diff --git a/LuaLibs/FacesBySaw.lua b/LuaLibs/FacesBySaw.lua index 7e263d9..3f3f54f 100644 --- a/LuaLibs/FacesBySaw.lua +++ b/LuaLibs/FacesBySaw.lua @@ -457,7 +457,7 @@ function FacesBySaw.MakeOne( nSurfId, nFacet, sCutting, dSawDiam, Par5, dVzLimDw -- se distanza al punto è maggiore del raggio lama, significa che non ho già lavorato, quindi calcolo entrata opportunamente if dDistPointToCenter > 0.5 * dSawDiam then dLiTang = -dAllStart * dCosAlpha - dLiPerp = dDist1 * dSinAlpha + dLiPerp = dDist1 * dSinAlpha end end -- se ho accorciato uscita, setto componente tangente e perpendicolare sul percorso di uscita diff --git a/LuaLibs/ProcessCut.lua b/LuaLibs/ProcessCut.lua index 064e709..8f0d645 100644 --- a/LuaLibs/ProcessCut.lua +++ b/LuaLibs/ProcessCut.lua @@ -479,12 +479,16 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b -- determino il modo di tagliare local vtOrthoO local bNoPerpCuts = false + local vtO + -- Se tagli ortogonali (indice dispari) if i % 2 == 1 then vtOrthoO = Vector3d( vtN) + -- Se tagli perpendicolari (indice pari) else - local vtO + -- Se elemento precedente contiene tagli ortogonali if #vCuts[i-1] > 0 then vtO = EgtSurfTmFacetNormVersor( vCuts[i-1][1], 0, GDB_ID.ROOT) + -- Se elemento successivo contiene tagli ortogonali elseif vCuts[i+1] and #vCuts[i+1] > 0 then -- lunghezza faccia nell'eventuale direzione ortogonale local asseX = EgtSurfTmFacetNormVersor( vCuts[i+1][1], 0, GDB_ID.ROOT) @@ -552,8 +556,46 @@ local function MakeFromTop( sCutting, Proc, nPhase, nRawId, nPartId, dOvmHead, b end local bOk2, sErr2 = Fbs.MakeOne( nSurfToCut, 0, sCutting, dSawDiam, nFaceUseCut2, nil, dCutExtra, BD.CUT_SIC, 0, 0, 0, '', b3Raw) if not bOk2 then return false, sErr2 end + -- caso standard else + if ( i % 2) == 0 and Proc.Fct == 1 and AreSameOrOppositeVectorApprox( vtO, Z_AX()) then + local vtOrthoVert = vtN ^ vtO + if ( vtN:getY() > 0 and vtOrthoVert:getY() > 0) or ( vtN:getY() < 0 and vtOrthoVert:getY() < 0) then + vtOrthoVert = -vtOrthoVert + end + local Frame = Frame3d( ptC, vtN, vtO) + local b3Fac = EgtGetBBoxRef( vCuts[i][1], GDB_BB.STANDARD, Frame) + if abs( b3Fac:getDimY() - BD.MAX_DIM_DICE) > 10 * GEO.EPS_SMALL then + local nVerticalCuts = ceil( b3Fac:getDimY() / ( BD.MAX_LEN_DICE)) - 1 + local dVerticalSliceDist = b3Fac:getDimY() / ( nVerticalCuts + 1) + local dSawDiam = 400 + if EgtMdbSetCurrMachining( sCutting) then + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if EgtTdbSetCurrTool( EgtTdbGetToolFromUUID( sTuuid) or '') then + dSawDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) or dSawDiam + end + end + -- tagli verticali + for k = 1, nVerticalCuts do + local nFaceUse = BL.GetNearestOrthoOpposite( vtN) + local dVerticalCutOffset = dVerticalSliceDist * k + local sLeadInOutType = 'Perpendicular' + local nMergedParallelSurfId = EgtSurfTmBySewing( nAddGrpId, vCuts[i], false) + local ptVertCut = EgtSurfTmFacetCenter( nMergedParallelSurfId, 0, GDB_ID.ROOT) + ptVertCut = ptVertCut + ( -b3Fac:getDimY()/2 + dVerticalCutOffset) * vtOrthoVert + local nSurfId = EgtSurfTmPlaneInBBox( nAddGrpId, ptVertCut, vtOrthoVert, b3Raw, GDB_RT.GLOB) + if i ~= 2 then + local nMergedPreviousParallelSurfId = EgtSurfTmBySewing( nAddGrpId, vCuts[i-2], false) + local ptOnPreviousParallelSurf = EgtSurfTmFacetCenter( nMergedPreviousParallelSurfId, 0, GDB_ID.ROOT) + EgtCutSurfTmPlane( nSurfId, ptOnPreviousParallelSurf, vtN, false, GDB_RT.GLOB) + end + EgtCutSurfTmPlane( nSurfId, ptVertCut, -vtN, false, GDB_RT.GLOB) + local bOk, sErr = Fbs.MakeOne( nSurfId, 0, sCutting, dSawDiam, nFaceUse, nil, -0.1, BD.CUT_SIC, 0, 0, 0, '', b3Raw, nil, nil, nil, sLeadInOutType, nil, 0, nil) + if not bOk then return bOk, sErr end + end + end + end -- lavoro la faccia for j = 1, #vCuts[i] do -- se taglio dal basso