diff --git a/LuaLibs/WProcessFreeContour.lua b/LuaLibs/WProcessFreeContour.lua index 5db1a01..395dda5 100644 --- a/LuaLibs/WProcessFreeContour.lua +++ b/LuaLibs/WProcessFreeContour.lua @@ -1,4 +1,4 @@ --- ProcessFreeContour.lua by Egaltech s.r.l. 2021/01/20 +-- ProcessFreeContour.lua by Egaltech s.r.l. 2021/02/18 -- Gestione calcolo profilo libero per Pareti -- Tabella per definizione modulo @@ -131,19 +131,38 @@ end --------------------------------------------------------------------- local function GetOtherRegions( nPartId) local vOthers = {} + -- ciclo sui pezzi local nOtherId = EgtGetFirstPartInRawPart( EgtGetFirstRawPart() or GDB_ID.NULL) while nOtherId do + -- cerco le regioni marcate + local nCount = 0 local nRegId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( nOtherId, 'Outline') or GDB_ID.NULL) while nRegId do local vtN = EgtSurfFrNormVersor( nRegId, GDB_ID.ROOT) if EgtExistsInfo( nRegId, 'REGION') and vtN and AreSameVectorApprox( vtN, Z_AX()) then local b3Reg = EgtGetBBoxGlob( nRegId, GDB_BB.STANDARD) if b3Reg then + nCount = nCount + 1 table.insert( vOthers, { PartId = nOtherId, RegId = nRegId, Box = b3Reg}) end end nRegId = EgtGetNext( nRegId) end + -- se non trovate regioni marcate, cerco regioni con la normale corretta + if nCount == 0 then + local nRegId = EgtGetFirstInGroup( EgtGetFirstNameInGroup( nOtherId, 'Outline') or GDB_ID.NULL) + while nRegId do + local vtN = EgtSurfFrNormVersor( nRegId, GDB_ID.ROOT) + if EgtGetType( nRegId) == GDB_TY.SRF_FRGN and vtN and AreSameVectorApprox( vtN, Z_AX()) then + local b3Reg = EgtGetBBoxGlob( nRegId, GDB_BB.STANDARD) + if b3Reg then + table.insert( vOthers, { PartId = nOtherId, RegId = nRegId, Box = b3Reg}) + end + end + nRegId = EgtGetNext( nRegId) + end + end + -- passo al pezzo successivo nOtherId = EgtGetNextPartInRawPart( nOtherId) end return vOthers @@ -358,6 +377,26 @@ local function GetFacesData( Proc, bOpposite, bCalclForBlade, dToolDiam, dToolMa EgtErase( WhId) end end + -- se ciclo chiuso + if ( abs( vFace[1].AngPrev) > 0.1) then + -- verifico se c'รจ un solo tipo 3 e nessun tipo 1 o 2 + local nInd3 + local nTot3 = 0 + local nTot12 = 0 + for i = 1, #vFace do + local Face = vFace[i] + if Face.Type == 1 or Face.Type == 2 then + nTot12 = nTot12 + 1 + elseif Face.Type == 3 then + nTot3 = nTot3 + 1 + nInd3 = i + end + end + -- se trovato il caso, trasformo il 3 in 4 (per evitare problemi con fresature con la stessa faccia a inizio e fine) + if nTot3 == 1 and nTot12 == 0 then + vFace[nInd3].Type = 4 + end + end -- eventuali stampe for i = 1, #vFace do local Face = vFace[i]