From 3b46a5b28569753d78ae0257b8802b4aa14a6766 Mon Sep 17 00:00:00 2001 From: "luca.mazzoleni" Date: Tue, 13 Dec 2022 09:48:53 +0100 Subject: [PATCH] BugFix/Approx3EdgesFaces: - in freeContour aggiunta la funzione Is3EdgesApprox per riconoscere come 3 lati anche facce con lati aggiuntivi molto corti (<15 mm) --- LuaLibs/WProcessFreeContour.lua | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index 2411020..503cdc7 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -12,6 +12,7 @@ -- 2022/04/26 Migliorata gestione caso pocketing. -- 2022/08/05 Aggiunta segnalazione aree vietate non gestite. -- 2022/08/29 Corretta gestione tipo Pocket senza fondo (sono lavorabili da entrambe le parti con fresatura). +-- 2022/12/13 Aggiunta la funzione Is3EdgesApprox per riconoscere come 3 lati anche facce con lati aggiuntivi molto corti (<15 mm) -- Tabella per definizione modulo local WPF = {} @@ -1233,6 +1234,33 @@ local function GetMaxDepth( vtNz, dMillDiam, dDiamTh, dMaxDepth, dFreeLen) end end +--------------------------------------------------------------------- +-- Funzione per determinare se la faccia ha lati molto corti (trascurabili) ed è quindi approssimabile ad una 3 facce +local function Is3EdgesApprox( Proc, nFacet, nAddGrpId) + local bResult = false + local nContourId = EgtExtractSurfTmFacetLoops( Proc.Id, nFacet, nAddGrpId) + EgtMergeCurvesInCurveCompo( nContourId) + -- recupero il numero effettivo di lati + local _, nEntityCount = EgtCurveDomain( nContourId) + local nEdges = nEntityCount + if nContourId then + if nEntityCount and nEntityCount == 3 then + bResult = true + -- rimuovo i lati molto corti dal conteggio totale + elseif nEntityCount then + for i = 1, nEntityCount do + local dLength = EgtCurveCompoLength( nContourId, i - 1) + if dLength < 15 then nEdges = nEdges - 1 end + end + end + if nEdges == 3 then bResult = true end + end + if bResult == true then + EgtOutLog( 'FreeContour : Face with ' .. tointeger( nEntityCount) .. ' edges skipped (approx 3 edges)') + end + return bResult +end + --------------------------------------------------------------------- local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAddGrpId) -- flag per fresature non passanti @@ -1358,8 +1386,10 @@ local function AddMillings( sMilling, vFace, Proc, nRawId, b3Raw, nConeCut, nAdd return 0, sErr end end + -- verifico se la faccia ha alcuni lati molto corti e può essere approssimata ad una 3 lati + local bIs3EdgesApprox = Is3EdgesApprox( Proc, vFace[i].Fac, nAddGrpId) -- se tutta la faccia o la sua fine senza taglio, inserisco una fresatura - if ( vFace[i].Type & 2) ~= 0 or ( vFace[i].Type == 4 and vFace[i].Edges > 3) then + if ( vFace[i].Type & 2) ~= 0 or ( vFace[i].Type == 4 and ( vFace[i].Edges > 3 and not bIs3EdgesApprox)) then -- inserisco la lavorazione local sName = 'Free_' .. ( EgtGetName( Proc.PartId) or tostring( Proc.PartId)) local nMchId = EgtAddMachining( sName, sMilling)