DataWall :

- correzioni e migliorie varie.
This commit is contained in:
DarioS
2022-03-20 19:05:21 +01:00
parent a126d8262c
commit ce99018cc2
4 changed files with 166 additions and 104 deletions
+101 -79
View File
@@ -147,7 +147,7 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
local bLJFromBottom = false
local nRectId
local vtFace = {}
local vtFace
local dMinCompZ = 0.95
if Proc.Fct == 2 then
@@ -157,13 +157,13 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
-- se rivolto verso il basso
if ( vtN[1]:getZ() < - dMinCompZ or vtN[2]:getZ() < - dMinCompZ) then
vtFace[1] = EgtIf( vtN[1]:getZ() < - dMinCompZ, vtN[2], vtN[1])
if not ( vtFace[1]:getZ() > dMinCompZ or vtFace[1]:getZ() < - dMinCompZ) then
vtFace = EgtIf( vtN[1]:getZ() < - dMinCompZ, vtN[2], vtN[1])
if not ( vtFace:getZ() > dMinCompZ or vtFace:getZ() < - dMinCompZ) then
bLJFromBottom = true
if bCompute then
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, 0, 1, GDB_ID.ROOT)
-- creo il rettangolo della lavorazione
nRectId = CreateToolRectangle( ptP1, WD.SIDEMILL_DIAM_DOWN / 2, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, WD.SIDEMILL_DIAM_DOWN / 2, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace, WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
end
end
end
@@ -175,14 +175,14 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
-- se nel mezzo di una faccia
if not nFacInd2 then
if nFacInd ~= -2 and nFacInd ~= GDB_ID.NULL then
vtFace[1] = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
if not ( vtFace[1]:getZ() > dMinCompZ or vtFace[1]:getZ() < - dMinCompZ) then
vtFace = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
if not ( vtFace:getZ() > dMinCompZ or vtFace:getZ() < - dMinCompZ) then
local nOtherFace = EgtIf( nFacInd == 0, 1, 0)
local bAdj, ptP1, ptP2, dAng = EgtSurfTmFacetsContact( Proc.Id, nFacInd, nOtherFace, GDB_ID.ROOT)
if abs( ptP1:getZ() - ptP2:getZ()) < GEO.EPS_SMALL then
bLJFromBottom = true
if bCompute then
nRectId = CreateToolRectangle( ptP1, WD.SIDEMILL_DIAM_DOWN / 2, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, WD.SIDEMILL_DIAM_DOWN / 2, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace, WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
end
end
end
@@ -201,8 +201,8 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
if nFaceZ ~= -1 then
local nFace = EgtIf( nFaceZ == nFacInd, nFacInd2, nFacInd)
local nOtherFace = EgtIf( nFaceZ + nFace == 3, 0, EgtIf( nFaceZ + nFace == 2, 1, 2))
vtFace[1] = EgtSurfTmFacetNormVersor( Proc.Id, nFace, GDB_ID.ROOT)
vtFace[2] = EgtSurfTmFacetNormVersor( Proc.Id, nOtherFace, GDB_ID.ROOT)
vtFace = EgtSurfTmFacetNormVersor( Proc.Id, nFace, GDB_ID.ROOT)
--vtFace[2] = EgtSurfTmFacetNormVersor( Proc.Id, nOtherFace, GDB_ID.ROOT)
bLJFromBottom = true
if bCompute then
local bAdj, ptP1, ptP2 = EgtSurfTmFacetsContact( Proc.Id, nFace, nFaceZ, GDB_ID.ROOT)
@@ -211,7 +211,7 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
ptP1, ptP2 = ptP2, ptP1
end
local dVal = EgtIf( NEST.MACH_AREA_IGNORE_3rdFACE == 1, WD.SIDEMILL_DIAM_DOWN / 2, 0)
nRectId = CreateToolRectangle( ptP1, dVal, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, dVal, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace, WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
end
end
end
@@ -219,9 +219,9 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
elseif Proc.Fct == 4 then
local nFacInd, dElev, nFacInd2, dElev2 = WL.GetFaceWithMostAdj( Proc.Id, Proc.PartId)
if nFacInd ~= -2 and nFacInd ~= GDB_ID.NULL then
vtFace[1] = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
vtFace = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd, GDB_ID.ROOT)
if not ( vtFace[1]:getZ() > dMinCompZ or vtFace[1]:getZ() < - dMinCompZ) then
if not ( vtFace:getZ() > dMinCompZ or vtFace:getZ() < - dMinCompZ) then
local nOtherFace = -1
for nIdx = 0, 3 do
local vtN2 = EgtSurfTmFacetNormVersor( Proc.Id, nIdx, GDB_ID.ROOT)
@@ -238,19 +238,19 @@ local function IdentifyLJFromBottom( Proc, bCompute, nOutlineGrp)
if AreSamePointApprox( ptP2, ptP3) or AreSamePointApprox( ptP2, ptP4) then
ptP1, ptP2 = ptP2, ptP1
end
nRectId = CreateToolRectangle( ptP1, 0, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, 0, ptP2, WD.SIDEMILL_DIAM_DOWN / 2, vtFace, WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
end
end
end
if nFacInd2 and nFacInd2 ~= GDB_ID.NULL then
local vtFace2 = EgtSurfTmFacetNormVersor( Proc.Id, nFacInd2, GDB_ID.ROOT)
if ( vtFace2:getZ() < - dMinCompZ or vtFace[1]:getZ() < - dMinCompZ) then
if ( vtFace2:getZ() < - dMinCompZ or vtFace:getZ() < - dMinCompZ) then
bLJFromBottom = true
if vtFace[1]:getZ() < -dMinCompZ then vtFace[1] = vtFace2 end
if vtFace:getZ() < -dMinCompZ then vtFace = vtFace2 end
if bCompute then
local bAdj, ptP1, ptP2 = EgtSurfTmFacetsContact( Proc.Id, nFacInd, nFacInd2, GDB_ID.ROOT)
nRectId = CreateToolRectangle( ptP1, 0, ptP2, 0, vtFace[1], WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, 0, ptP2, 0, vtFace, WD.SIDEMILL_DIAM_DOWN, nOutlineGrp)
end
end
end
@@ -336,8 +336,8 @@ local function IdentifyLJFromTop( Proc, bCompute, nOutlineGrp)
local nFace = EgtIf( nFaceZ == nFacInd, nFacInd2, nFacInd)
local nOtherFace = EgtIf( nFaceZ + nFace == 3, 0, EgtIf( nFaceZ + nFace == 2, 1, 2))
local vtFace = {}
vtFace[1] = EgtSurfTmFacetNormVersor( Proc.Id, nFace, GDB_ID.ROOT)
vtFace[2] = EgtSurfTmFacetNormVersor( Proc.Id, nOtherFace, GDB_ID.ROOT)
vtFace = EgtSurfTmFacetNormVersor( Proc.Id, nFace, GDB_ID.ROOT)
--vtFace = EgtSurfTmFacetNormVersor( Proc.Id, nOtherFace, GDB_ID.ROOT)
bLJFromTop = true
if bCompute then
local bAdj, ptP1, ptP2 = EgtSurfTmFacetsContact( Proc.Id, nFace, nFaceZ, GDB_ID.ROOT)
@@ -348,9 +348,9 @@ local function IdentifyLJFromTop( Proc, bCompute, nOutlineGrp)
local b3Face = EgtSurfTmGetFacetBBoxGlob( Proc.Id, nFaceZ, GDB_BB.STANDARD)
local dDim = 0
if vtFace[1]:getX() > dMinComp or vtFace[1]:getX() < - dMinComp then
if vtFace:getX() > dMinComp or vtFace:getX() < - dMinComp then
dDim = b3Face:getDimX()
elseif vtFace[1]:getY() > dMinComp or vtFace[1]:getY() < - dMinComp then
elseif vtFace:getY() > dMinComp or vtFace:getY() < - dMinComp then
dDim = b3Face:getDimY()
end
local dValFace = max( dDim + WD.SIDEMILL_DIAM_UP / 2, WD.SIDEMILL_DIAM_UP)
@@ -358,7 +358,7 @@ local function IdentifyLJFromTop( Proc, bCompute, nOutlineGrp)
if NEST.MACH_AREA_USE_OTHER_DIAM == 1 then
dVal = NEST.MACH_AREA_OTHER_DIAM / 2
end
nRectId = CreateToolRectangle( ptP1, 0, ptP2, dVal, vtFace[1], dValFace, nOutlineGrp)
nRectId = CreateToolRectangle( ptP1, 0, ptP2, dVal, vtFace, dValFace, nOutlineGrp)
end
end
end
@@ -666,18 +666,16 @@ local function ClassifyLapJointsFromBottom( nPartId)
if LapJoint.Identify( vPartProc[nInd]) then
-- verifico se LJ da sotto
local vtFace = IdentifyLJFromBottom( vPartProc[nInd], false)
if vtFace then
for nInd2 = 1, #vtFace do
if vtFace[nInd2]:getX() > dMinComponentVal then
vtLapJoints["R"] = 1
elseif vtFace[nInd2]:getX() < - dMinComponentVal then
vtLapJoints["L"] = 1
elseif vtFace[nInd2]:getY() > dMinComponentVal then
vtLapJoints["B"] = 1
elseif vtFace[nInd2]:getY() < - dMinComponentVal then
vtLapJoints["F"] = 1
end
end
if vtFace then
if vtFace:getX() > dMinComponentVal then
vtLapJoints["R"] = 1
elseif vtFace:getX() < - dMinComponentVal then
vtLapJoints["L"] = 1
elseif vtFace:getY() > dMinComponentVal then
vtLapJoints["B"] = 1
elseif vtFace:getY() < - dMinComponentVal then
vtLapJoints["F"] = 1
end
end
end
end
@@ -857,7 +855,8 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
local nAngle
local nRotate = 0
local bOptimal
local bManual = false
local bManual = false
local bOnly180Rot = EgtGetInfo( nPartId, "HasGrainDirection", 'b') or false
local b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD)
-- fori
@@ -882,41 +881,63 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
RotationAngles = { F = 180, B = 0, L = 270, R = 90}
else
RotationAngles = { F = 0, B = 180, L = 90, R = 270}
end
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif.sCase]
-- verifico se la rotazione è valida
local nBoxLayerId = EgtGetFirstNameInGroup( nPartId, "Box")
local nBoxId = EgtGetFirstNameInGroup( nBoxLayerId, "Box")
local b3Part = EgtGetBBoxGlob(nBoxId, GDB_BB.STANDARD)
-- b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD)
local bIsValidRotation = b3Part:getDimX() < RawPart.Len - 2 * NEST.KERF + GEO.EPS_SMALL and b3Part:getDimY() < RawPart.Width - 2 * NEST.KERF + GEO.EPS_SMALL
if not bIsValidRotation then
-- ritorno nella posizione originaria
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), - RotationAngles[DrillClassif.sCase], GDB_RT.GLOB)
nRotate = nRotate - RotationAngles[DrillClassif.sCase]
-- se ho un'altra posizione possibile ruoto in quella
if DrillClassif2 then
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif2.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif2.sCase]
bDrillOpen = not DrillClassif2.bClosed
bLongDrill = DrillClassif2.bLong
if DrillClassif2.bOnlyOnRef then
EgtSetInfo( nPartId, "OnlyOnRefSide", 1)
end
else
-- dimentico di avere il foro
bDrill = false
end
end
-- se rotazione è libera
if not bOnly180Rot then
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif.sCase]
-- verifico se la rotazione è valida
local nBoxLayerId = EgtGetFirstNameInGroup( nPartId, "Box")
local nBoxId = EgtGetFirstNameInGroup( nBoxLayerId, "Box")
local b3Part = EgtGetBBoxGlob(nBoxId, GDB_BB.STANDARD)
-- b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD)
local bIsValidRotation = b3Part:getDimX() < RawPart.Len - 2 * NEST.KERF + GEO.EPS_SMALL and b3Part:getDimY() < RawPart.Width - 2 * NEST.KERF + GEO.EPS_SMALL
if not bIsValidRotation then
-- ritorno nella posizione originaria
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), - RotationAngles[DrillClassif.sCase], GDB_RT.GLOB)
nRotate = nRotate - RotationAngles[DrillClassif.sCase]
-- se ho un'altra posizione possibile ruoto in quella
if DrillClassif2 then
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif2.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif2.sCase]
bDrillOpen = not DrillClassif2.bClosed
bLongDrill = DrillClassif2.bLong
if DrillClassif2.bOnlyOnRef then
EgtSetInfo( nPartId, "OnlyOnRefSide", 1)
end
else
-- dimentico di avere il foro
bDrill = false
end
end
-- se posso ruotare solo di 180° per venatura
else
if RotationAngles[DrillClassif.sCase] == 0 or RotationAngles[DrillClassif.sCase] == 180 then
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif.sCase]
else
-- vedo se ho un'altra posizione possibile
if DrillClassif2 and ( RotationAngles[DrillClassif2.sCase] == 0 or RotationAngles[DrillClassif2.sCase] == 180) then
EgtRotate( nPartId, b3Part:getCenter(), Z_AX(), RotationAngles[DrillClassif2.sCase], GDB_RT.GLOB)
nRotate = nRotate + RotationAngles[DrillClassif2.sCase]
bDrillOpen = not DrillClassif2.bClosed
bLongDrill = DrillClassif2.bLong
if DrillClassif2.bOnlyOnRef then
EgtSetInfo( nPartId, "OnlyOnRefSide", 1)
end
else
-- dimentico di avere il foro
bDrill = false
end
end
end
end
-- se non ho fori scelgo una posizione che non faccia cadere il pezzo
local bOnly180Rot = false
if not bDrill and not bLockedRot then
-- se non ho venature e fori scelgo una posizione che non faccia cadere il pezzo
if not bDrill and not bOnly180Rot and not bLockedRot then
b3Part = EgtGetBBoxGlob( nPartId, GDB_BB.STANDARD)
local bIsValid = b3Part:getDimX() > ( WD.INTRULLI or 1200)
local bRotatedIsValid = b3Part:getDimY() > ( WD.INTRULLI or 1200)
@@ -948,7 +969,9 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
end
-- se anche fori oppure possibile solo rotazione di 180° per non far cadere il pezzo
if bDrill or bOnly180Rot then
if bDrill or bOnly180Rot then
local bCanRotate = not bDrill or ( bDrill and bDrillOpen)
if ResLapJoints.Nbr == 0 then
nAngle = 0
if not bDrill then bAdd = false end
@@ -959,20 +982,20 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
nAngle = 20
elseif (( sRefOrig == 'TL' or sRefOrig == 'TR') and ResLapJoints.sCase == 'F' ) or
(( sRefOrig == 'BL' or sRefOrig == 'BR') and ResLapJoints.sCase == 'B' ) then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 20, 100)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 20, 100)
nRotate = nRotate + nRotate2
elseif ResLapJoints.sCase == 'R' then
if bDrillOpen or bOnly180Rot then bManual = true end
if bCanRotate then bManual = true end
if sRefOrig == 'TL' or sRefOrig == 'BL'then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 40, 0)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 40, 0)
nRotate = nRotate + nRotate2
else
nAngle = 40
end
elseif ResLapJoints.sCase == 'L' then
if bDrillOpen or bOnly180Rot then bManual = true end
if bCanRotate then bManual = true end
if sRefOrig == 'TR' or sRefOrig == 'BR' then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 40, 0)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 40, 0)
nRotate = nRotate + nRotate2
else
nAngle = 40
@@ -991,7 +1014,7 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
(( sRefOrig == 'BL' or sRefOrig == 'BR') and (ResLapJoints.sCase == 'FL' or ResLapJoints.sCase == 'FR')) then
nAngle = 40
else
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 40, 100)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 40, 100)
nRotate = nRotate + nRotate2
end
end
@@ -1002,19 +1025,19 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
nAngle = 80
elseif (( sRefOrig == 'TL' or sRefOrig == 'TR') and ResLapJoints.sCase == 'B' ) or
(( sRefOrig == 'BL' or sRefOrig == 'BR') and ResLapJoints.sCase == 'F' ) then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 80, 100)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 80, 100)
nRotate = nRotate + nRotate2
elseif ResLapJoints.sCase == 'R' then
if bDrillOpen or bOnly180Rot then bManual = true end
if bCanRotate then bManual = true end
if sRefOrig == 'TR' or sRefOrig == 'BR' then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 100, 100)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 100, 100)
nRotate = nRotate + nRotate2
end
nAngle = 100
elseif ResLapJoints.sCase == 'L' then
if bDrillOpen or bOnly180Rot then bManual = true end
if bCanRotate then bManual = true end
if sRefOrig == 'TL' or sRefOrig == 'BL' then
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bDrillOpen or bOnly180Rot, 100, 100)
nAngle, nRotate2 = RotateOptimalCaseDrill( nPartId, bCanRotate, 100, 100)
nRotate = nRotate + nRotate2
end
nAngle = 100
@@ -1120,8 +1143,7 @@ local function ClassifyAngles( nPartId, RawPart, sRefOrig, bLockedRot, dMinSheet
if b3Part:getDimX() > ( WD.INTRULLI or 1200) then
EgtSetInfo( nPartId, "REDUCECUT", 1)
end
return PartAngleClassification
end