- in WallLib -> affectedFaces modificata tolleranza
- in WallExec introduzione costanti distinte per tolleranze ricerca tasche e fori in doppio - altre piccole migliorie
This commit is contained in:
+68
-54
@@ -640,26 +640,47 @@ function InsertScrapRemoval( nPhase)
|
||||
EgtSetCurrMachining( nActiveMachiningId or GDB_ID.NULL)
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- funzione per l'ordinamento delle features in doppio da accoppiare
|
||||
-- ordinate prima in base alla X e poi alla Y
|
||||
local function SortFeaturesForMirror( Proc1, Proc2)
|
||||
local TOL = EgtIf( Proc1.TopologyLongName == 'DRILLING', WD.DOUBLE_HEAD_DRILLING_TOLERANCE , WD.DOUBLE_HEAD_POCKET_TOLERANCE)
|
||||
local Proc1X = Proc1.Box:getCenter():getX()
|
||||
local Proc1Y = Proc1.Box:getCenter():getY()
|
||||
local Proc2X = Proc2.Box:getCenter():getX()
|
||||
local Proc2Y = Proc2.Box:getCenter():getY()
|
||||
if Proc1X < Proc2X - TOL then
|
||||
return true
|
||||
elseif abs( Proc1X - Proc2X) < TOL then
|
||||
if Proc1Y < Proc2Y - TOL then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
-- Controlla in vProc la presenza di feature da lavorare in doppio e, se trovate, ne setta i parametri
|
||||
local function SetMirroredFeatures( vProc, b3Raw)
|
||||
|
||||
local dMinimumDistanceMirroredFeatures = 780
|
||||
local vGroovesThrough = {}
|
||||
local vDrillings = {}
|
||||
|
||||
-- in base alla topologia cerco subito la feature mirror oppure raccolgo tutte le feature simili e le accoppio successivamente
|
||||
for i = 1, #vProc do
|
||||
local Proc = vProc[i]
|
||||
if Proc.Flg ~= 0 then
|
||||
-- AGGIUNGERE DIPENDENZA DA COSTANTE WALLDATA!!
|
||||
-- tutte le rabbet, tunnel e groove, tranne le groove passanti che guardano Z+, vengono confrontati con possibili feature mirror
|
||||
if Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2'or
|
||||
Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' or
|
||||
Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' or
|
||||
Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' or
|
||||
( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) then
|
||||
-- feature rivolta verso Y- e parallela a X
|
||||
local bIsFeatureFacingFrontSide = Proc.AffectedFaces.Front
|
||||
-- tutte le rabbet, tunnel e groove sul fianco vengono confrontate con possibili feature mirror
|
||||
if WD.DOUBLE_HEAD_POCKET and
|
||||
(
|
||||
( Proc.TopologyLongName == 'Rabbet-Through-RightAngles-Parallel-2' and Proc.AffectedFaces.Front) or
|
||||
( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-3' and Proc.AffectedFaces.Front) or
|
||||
( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Front) or
|
||||
( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Front) or
|
||||
( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Front and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right)
|
||||
) then
|
||||
-- feature vicino al bordo Y- del grezzo
|
||||
local bIsFeatureOnEdge = false
|
||||
local bIsFeatureOnEdgeOrPocket = false
|
||||
local nFaceLookingFrontSide
|
||||
for j = 1, Proc.Fct do
|
||||
if AreOppositeVectorApprox( Proc.Face[j].VtN, Y_AX()) then
|
||||
@@ -670,20 +691,21 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
if nFaceLookingFrontSide then
|
||||
local ptFaceCenter = EgtSurfTmFacetCenter( Proc.Id, nFaceLookingFrontSide, GDB_ID.ROOT)
|
||||
local dSideDist = abs( ptFaceCenter:getY() - b3Raw:getMin():getY())
|
||||
bIsFeatureOnEdge = bIsFeatureFacingFrontSide and ( dSideDist < dMaxDist)
|
||||
bIsFeatureOnEdgeOrPocket = dSideDist < dMaxDist
|
||||
end
|
||||
-- mirror XY sul lato opposto
|
||||
local nMirrorId
|
||||
local dYMirrorAx
|
||||
local dDeltaZ
|
||||
local bIsMirrorTowardsBottom = false
|
||||
-- cerco una possibile feature mirror
|
||||
for j = 1, #vProc do
|
||||
local ProcMirror = vProc[j]
|
||||
if ProcMirror.TopologyLongName == Proc.TopologyLongName and ProcMirror.Id ~= Proc.Id and ProcMirror.Flg ~= 0 then
|
||||
-- feature specchiata rivolta verso Y+ e parallela a X
|
||||
local bIsMirrorFeatureFacingBackSide = EgtIf( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3', ProcMirror.AffectedFaces.Back and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right, ProcMirror.AffectedFaces.Back)
|
||||
-- feature specchiata vicino al bordo Y+ del grezzo
|
||||
local bIsMirrorFeatureOnEdge = false
|
||||
local bIsMirrorFeatureOnEdgeOrPocket = false
|
||||
local nMirrorFaceLookingBackSide
|
||||
for k = 1, ProcMirror.Fct do
|
||||
if AreSameVectorApprox( ProcMirror.Face[k].VtN, Y_AX()) then
|
||||
@@ -693,24 +715,24 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
if nMirrorFaceLookingBackSide then
|
||||
local ptMirrorFaceCenter = EgtSurfTmFacetCenter( ProcMirror.Id, nMirrorFaceLookingBackSide, GDB_ID.ROOT)
|
||||
local dMirrorSideDist = abs( ptMirrorFaceCenter:getY() - b3Raw:getMax():getY())
|
||||
bIsMirrorFeatureOnEdge = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist)
|
||||
bIsMirrorFeatureOnEdgeOrPocket = bIsMirrorFeatureFacingBackSide and ( dMirrorSideDist < dMaxDist)
|
||||
end
|
||||
-- box delle stesse dimensioni
|
||||
local bIsMirrorFeatureSameDimension = false
|
||||
local b3Proc = EgtGetBBoxGlob( Proc.Id, GDB_BB.STANDARD)
|
||||
local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD)
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5)
|
||||
-- box allineati in X
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5
|
||||
-- box che non si intersecano
|
||||
local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror)
|
||||
-- distanza minima tra le feature
|
||||
local dYMinDistance = max( b3Proc:getMin():getY(), b3ProcMirror:getMin():getY()) - min( b3Proc:getMax():getY(), b3ProcMirror:getMax():getY())
|
||||
local bIsMirrorFeatureDistanceOk = dYMinDistance > dMinimumDistanceMirroredFeatures + 10 * GEO.EPS_SMALL
|
||||
-- se tutte vere le condizioni, calcolo i parametri da passare alle lavorazioni
|
||||
if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdge and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then
|
||||
if bIsMirrorFeatureFacingBackSide and bIsMirrorFeatureOnEdgeOrPocket and bIsMirrorFeatureSameDimension and bIsMirrorBoxXAligned and bIsNotMirrorBoxOverlapping and bIsMirrorFeatureDistanceOk then
|
||||
nMirrorId = ProcMirror.Id
|
||||
local b3Tab = EgtGetTableArea()
|
||||
local ptOnMirrorAx = ( Proc.Box:getCenter() + ProcMirror.Box:getCenter()) / 2
|
||||
@@ -720,8 +742,8 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- se le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione
|
||||
if nMirrorId and bIsFeatureFacingFrontSide and bIsFeatureOnEdge then
|
||||
-- se ho trovato una feature mirror e le condizioni precedenti sono soddisfatte, posso scrivere i parametri nella lavorazione
|
||||
if nMirrorId and bIsFeatureOnEdgeOrPocket then
|
||||
-- 2: specchiatura in Y
|
||||
Proc.Double = 2
|
||||
Proc.MirrorId = nMirrorId
|
||||
@@ -735,18 +757,22 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
Proc.Stype = 2
|
||||
end
|
||||
end
|
||||
-- le groove passanti, parallele a X e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio
|
||||
elseif Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right then
|
||||
-- le groove non sul fianco e rivolte verso Z+ vanno raccolte, ordinate e accoppiate a 2 a 2 per il doppio
|
||||
elseif WD.DOUBLE_HEAD_POCKET and
|
||||
(
|
||||
( Proc.TopologyLongName == 'Groove-Through-RightAngles-Parallel-3' and Proc.AffectedFaces.Top and Proc.AffectedFaces.Left and Proc.AffectedFaces.Right) or
|
||||
( Proc.TopologyLongName == 'Groove-Blind-RightAngles-Parallel-4' and Proc.AffectedFaces.Top and ( Proc.AffectedFaces.Left or Proc.AffectedFaces.Right)) or
|
||||
( Proc.TopologyLongName == 'Tunnel-Blind-RightAngles-Parallel-5' and Proc.AffectedFaces.Top)
|
||||
) then
|
||||
table.insert( vGroovesThrough, Proc)
|
||||
-- i fori verticali e aperti verso Z+ vanno raccolti, ordinati e accoppiati a 2 a 2 per il doppio a parità di X
|
||||
elseif Proc.TopologyLongName == 'DRILLING' then
|
||||
-- recupero e verifico l'entità foro
|
||||
elseif WD.DOUBLE_HEAD_DRILLING and Proc.TopologyLongName == 'DRILLING' then
|
||||
-- recupero e verifico la geometria del foro
|
||||
local AuxId = EgtGetInfo( Proc.Id, 'AUXID', 'i') or 0
|
||||
if AuxId then AuxId = AuxId + Proc.Id end
|
||||
if not AuxId or EgtGetType( AuxId) ~= GDB_TY.CRV_ARC then
|
||||
return false
|
||||
end
|
||||
-- recupero il vettore del foro
|
||||
local vtExtr = EgtCurveExtrusion( AuxId, GDB_RT.GLOB)
|
||||
if Proc.AffectedFaces.Top and AreSameOrOppositeVectorApprox( vtExtr, Z_AX()) then
|
||||
table.insert( vDrillings, Proc)
|
||||
@@ -755,25 +781,11 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
end
|
||||
end
|
||||
|
||||
-- ordino le groove passanti rivolte verso Z+ in base alla Y crescente
|
||||
table.sort( vGroovesThrough, function( a, b) return b.Box:getCenter():getY() > a.Box:getCenter():getY() end)
|
||||
|
||||
-- funzione per l'ordinamento dei fori
|
||||
local function SortDrillingsForMirror( Proc1, Proc2)
|
||||
local Proc1X = Proc1.Box:getCenter():getX()
|
||||
local Proc1Y = Proc1.Box:getCenter():getY()
|
||||
local Proc2X = Proc2.Box:getCenter():getX()
|
||||
local Proc2Y = Proc2.Box:getCenter():getY()
|
||||
if Proc1X < Proc2X - 10 * GEO.EPS_SMALL then
|
||||
return true
|
||||
elseif abs( Proc1X - Proc2X) < 10 * GEO.EPS_SMALL then
|
||||
if Proc1Y < Proc2Y - 10 * GEO.EPS_SMALL then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
-- ordino le forature aperte verso Z+ in base alla X e poi alla Y crescente
|
||||
table.sort( vDrillings, SortDrillingsForMirror)
|
||||
-- ordinamento delle feature che vanno accoppiate
|
||||
-- groove verso Z+
|
||||
table.sort( vGroovesThrough, SortFeaturesForMirror)
|
||||
-- forature verso Z+
|
||||
table.sort( vDrillings, SortFeaturesForMirror)
|
||||
|
||||
-- accoppio le groove passanti rivolte verso Z+
|
||||
local nCurrentGroove = 1
|
||||
@@ -785,15 +797,15 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
while nCurrentMirrorGroove <= #vGroovesThrough do
|
||||
local ProcMirror = vGroovesThrough[nCurrentMirrorGroove]
|
||||
local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD)
|
||||
-- feature non disattivata e diversa dala i-esima
|
||||
-- feature non disattivata e diversa da nCurrentGroove
|
||||
local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0)
|
||||
-- box delle stesse dimensioni
|
||||
local bIsMirrorFeatureSameDimension = false
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5) and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5)
|
||||
-- box allineati in X
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 500 * GEO.EPS_SMALL
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < ( WD.DOUBLE_HEAD_POCKET_TOLERANCE or 0.5)
|
||||
-- box che non si intersecano
|
||||
local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror)
|
||||
-- distanza minima tra le feature
|
||||
@@ -814,6 +826,7 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
-- rimuovo dalla lista le groove già assegnate
|
||||
local ProcMirrorOldId = ProcMirror.Id
|
||||
table.remove( vGroovesThrough, nCurrentGroove)
|
||||
-- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorGroove
|
||||
if nCurrentMirrorGroove > #vGroovesThrough or ( vGroovesThrough[nCurrentMirrorGroove].Id ~= ProcMirrorOldId) then nCurrentMirrorGroove = nCurrentMirrorGroove - 1 end
|
||||
table.remove( vGroovesThrough, nCurrentMirrorGroove)
|
||||
nCurrentGroove = 0
|
||||
@@ -835,15 +848,15 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
while nCurrentMirrorDrilling <= #vDrillings do
|
||||
local ProcMirror = vDrillings[nCurrentMirrorDrilling]
|
||||
local b3ProcMirror = EgtGetBBoxGlob( ProcMirror.Id, GDB_BB.STANDARD)
|
||||
-- feature non disattivata e diversa dala i-esima
|
||||
-- feature non disattivata e diversa da nCurrentDrilling
|
||||
local bIsMirrorIdOk = ( Proc.Id ~= ProcMirror.Id and ProcMirror.Flg ~= 0)
|
||||
-- box delle stesse dimensioni
|
||||
local bIsMirrorFeatureSameDimension = false
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < 500 * GEO.EPS_SMALL and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < 500 * GEO.EPS_SMALL
|
||||
bIsMirrorFeatureSameDimension = abs( b3Proc:getDimX() - b3ProcMirror:getDimX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and
|
||||
abs( b3Proc:getDimY() - b3ProcMirror:getDimY()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1) and
|
||||
abs( b3Proc:getDimZ() - b3ProcMirror:getDimZ()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1)
|
||||
-- box allineati in X
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < 10 * GEO.EPS_SMALL
|
||||
local bIsMirrorBoxXAligned = abs( Proc.Box:getCenter():getX() - ProcMirror.Box:getCenter():getX()) < ( WD.DOUBLE_HEAD_DRILLING_TOLERANCE or 0.1)
|
||||
-- box che non si intersecano
|
||||
local bIsNotMirrorBoxOverlapping = not OverlapsXY( b3Proc, b3ProcMirror)
|
||||
-- distanza minima tra le feature
|
||||
@@ -864,6 +877,7 @@ local function SetMirroredFeatures( vProc, b3Raw)
|
||||
-- rimuovo dalla lista le groove già assegnate
|
||||
local ProcMirrorOldId = ProcMirror.Id
|
||||
table.remove( vDrillings, nCurrentDrilling)
|
||||
-- avendo rimosso un elemento dall'array, potrebbe essere cambiato l'elemento nCurrentMirrorDrilling
|
||||
if nCurrentMirrorDrilling > #vDrillings or ( vDrillings[nCurrentMirrorDrilling].Id ~= ProcMirrorOldId) then nCurrentMirrorDrilling = nCurrentMirrorDrilling - 1 end
|
||||
table.remove( vDrillings, nCurrentMirrorDrilling)
|
||||
nCurrentDrilling = 0
|
||||
|
||||
Reference in New Issue
Block a user