From ade9d3ffe9fd853ce8dbfc6a7b0b34b81e2db362 Mon Sep 17 00:00:00 2001 From: SaraP Date: Fri, 2 Dec 2022 17:58:39 +0100 Subject: [PATCH] DataWall : - nel nesting aggiunto controllo sul diametro dei fori - in FlipAndRot corretto controllo sulle rotazioni. --- NestFlipAndRotate.lua | 11 ++-- NestProcess.lua | 132 ++++++++++++++++++++++-------------------- 2 files changed, 74 insertions(+), 69 deletions(-) diff --git a/NestFlipAndRotate.lua b/NestFlipAndRotate.lua index 4571168..a19c747 100644 --- a/NestFlipAndRotate.lua +++ b/NestFlipAndRotate.lua @@ -349,16 +349,17 @@ if not bManualRot then local nRotateOpt = 0 if #RotateFeatureStates > 0 then -- calcolo lato con punteggio minore o molteplicita' piu' alta - local nRotMax = 0 - local nScoreMax = 0 - local nScoreCnt = 0 - for nInd = 1, #MinList do + local nRotMax = MinList[1].Rot + local nScoreMax = MinList[1].Score + local nScoreCnt = MinList[1].ScoreCnt + for nInd = 2, #MinList do if MinList[nInd].Score > nScoreMax then nRotMax = MinList[nInd].Rot nScoreMax = MinList[nInd].Score nScoreCnt = MinList[nInd].ScoreCnt elseif MinList[nInd].Score == nScoreMax then - if MinList[nInd].ScoreCnt > nScoreCnt then + -- se punteggio > 0 conservo quello con molteplicità più alta, se punteggio = 0 conservo quello con molteplicità più bassa + if ( nScoreMax ~= 0 and MinList[nInd].ScoreCnt > nScoreCnt) or ( nScoreMax == 0 and MinList[nInd].ScoreCnt < nScoreCnt) then nRotMax = MinList[nInd].Rot nScoreMax = MinList[nInd].Score nScoreCnt = MinList[nInd].ScoreCnt diff --git a/NestProcess.lua b/NestProcess.lua index 975215b..02c904b 100644 --- a/NestProcess.lua +++ b/NestProcess.lua @@ -509,80 +509,84 @@ local function ClassifyDrillsOnLateralFaces( nPartId, dMinSheetWidth) local vPartProc = WE.CollectFeatures( nPartId) for nInd = 1, #vPartProc do repeat - if Drill.Identify( vPartProc[nInd]) then + if Drill.Identify( vPartProc[nInd]) then -- identifico su quali facce si trova il foro local bOpen = ( vPartProc[nInd].Fcs ~= 0 and vPartProc[nInd].Fce ~= 0) local AuxId = EgtGetInfo( vPartProc[nInd].Id, 'AUXID', 'i') or 0 if AuxId then AuxId = AuxId + vPartProc[nInd].Id end - if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then break end - local ptDrill = EgtCP( AuxId, GDB_RT.GLOB) - local dLen = abs( EgtCurveThickness( AuxId)) - local bLong = dLen > WD.HOR_DRILL_LEN - 1 - local bOnlyOnRef = dLen + dDeltaRaw > WD.HOR_DRILL_LEN - GEO.EPS_SMALL and not bLong - - -- faccia Front - local dTol = GEO.EPS_SMALL - if ( abs( ptDrill:getY() - ptPartMin:getY()) < dTol) then - DrillOnFaces.F.nbr = DrillOnFaces.F.nbr + 1 - if bOnlyOnRef then DrillOnFaces.F.OnlyOnRef = true end - if bOpen then - DrillOnFaces.B.nbr = DrillOnFaces.B.nbr + 1 - if bOnlyOnRef then DrillOnFaces.B.OnlyOnRef = true end - else - DrillOnFaces.F.closed = true - - end - if bLong then - DrillOnFaces.F.long = true - if bOpen then DrillOnFaces.B.long = true end - end + if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then break end + -- verifico se diametro compatibile con la punta + local dDiam = 2 * EgtArcRadius( AuxId) + if abs( dDiam - WD.HOR_DRILL_DIAM) < WD.DRILL_TOL + GEO.EPS_SMALL then + local ptDrill = EgtCP( AuxId, GDB_RT.GLOB) + local dLen = abs( EgtCurveThickness( AuxId)) + local bLong = dLen > WD.HOR_DRILL_LEN - 1 + local bOnlyOnRef = dLen + dDeltaRaw > WD.HOR_DRILL_LEN - GEO.EPS_SMALL and not bLong - -- faccia Back - elseif ( abs( ptDrill:getY() - ptPartMax:getY()) < dTol) then - DrillOnFaces.B.nbr = DrillOnFaces.B.nbr + 1 - if bOnlyOnRef then DrillOnFaces.B.OnlyOnRef = true end - if bOpen then + -- faccia Front + local dTol = GEO.EPS_SMALL + if ( abs( ptDrill:getY() - ptPartMin:getY()) < dTol) then DrillOnFaces.F.nbr = DrillOnFaces.F.nbr + 1 - if bOnlyOnRef then DrillOnFaces.F.OnlyOnRef = true end - else - DrillOnFaces.B.closed = true - end - if bLong then - DrillOnFaces.B.long = true - if bOpen then DrillOnFaces.F.long = true end - end - - -- faccia Left - elseif ( abs( ptDrill:getX() - ptPartMin:getX()) < dTol) then - DrillOnFaces.L.nbr = DrillOnFaces.L.nbr + 1 - if bOnlyOnRef then DrillOnFaces.L.OnlyOnRef = true end - if bOpen then - DrillOnFaces.R.nbr = DrillOnFaces.R.nbr + 1 - if bOnlyOnRef then DrillOnFaces.R.OnlyOnRef = true end - else - DrillOnFaces.L.closed = true - end + if bOnlyOnRef then DrillOnFaces.F.OnlyOnRef = true end + if bOpen then + DrillOnFaces.B.nbr = DrillOnFaces.B.nbr + 1 + if bOnlyOnRef then DrillOnFaces.B.OnlyOnRef = true end + else + DrillOnFaces.F.closed = true + + end + if bLong then + DrillOnFaces.F.long = true + if bOpen then DrillOnFaces.B.long = true end + end + + -- faccia Back + elseif ( abs( ptDrill:getY() - ptPartMax:getY()) < dTol) then + DrillOnFaces.B.nbr = DrillOnFaces.B.nbr + 1 + if bOnlyOnRef then DrillOnFaces.B.OnlyOnRef = true end + if bOpen then + DrillOnFaces.F.nbr = DrillOnFaces.F.nbr + 1 + if bOnlyOnRef then DrillOnFaces.F.OnlyOnRef = true end + else + DrillOnFaces.B.closed = true + end if bLong then - DrillOnFaces.L.long = true - if bOpen then DrillOnFaces.R.long = true end - end - - -- faccia Right - elseif ( abs( ptDrill:getX() - ptPartMax:getX()) < dTol) then - DrillOnFaces.R.nbr = DrillOnFaces.R.nbr + 1 - if bOnlyOnRef then DrillOnFaces.R.OnlyOnRef = true end - if bOpen then - DrillOnFaces.L.nbr = DrillOnFaces.L.nbr + 1 + DrillOnFaces.B.long = true + if bOpen then DrillOnFaces.F.long = true end + end + + -- faccia Left + elseif ( abs( ptDrill:getX() - ptPartMin:getX()) < dTol) then + DrillOnFaces.L.nbr = DrillOnFaces.L.nbr + 1 if bOnlyOnRef then DrillOnFaces.L.OnlyOnRef = true end - else - DrillOnFaces.R.closed = true - end - if bLong then - DrillOnFaces.R.long = true - if bOpen then DrillOnFaces.L.long = true end + if bOpen then + DrillOnFaces.R.nbr = DrillOnFaces.R.nbr + 1 + if bOnlyOnRef then DrillOnFaces.R.OnlyOnRef = true end + else + DrillOnFaces.L.closed = true + end + if bLong then + DrillOnFaces.L.long = true + if bOpen then DrillOnFaces.R.long = true end + end + + -- faccia Right + elseif ( abs( ptDrill:getX() - ptPartMax:getX()) < dTol) then + DrillOnFaces.R.nbr = DrillOnFaces.R.nbr + 1 + if bOnlyOnRef then DrillOnFaces.R.OnlyOnRef = true end + if bOpen then + DrillOnFaces.L.nbr = DrillOnFaces.L.nbr + 1 + if bOnlyOnRef then DrillOnFaces.L.OnlyOnRef = true end + else + DrillOnFaces.R.closed = true + end + if bLong then + DrillOnFaces.R.long = true + if bOpen then DrillOnFaces.L.long = true end + end end - end + end end until true