- in FACEBYBLADE completata IsOrientationOkForDownUp; rimane da fare GetCorrectedElevationDownUp

This commit is contained in:
luca.mazzoleni
2025-10-29 15:29:40 +01:00
parent 21bb95c0e9
commit 9468e3d013
+45 -96
View File
@@ -203,12 +203,14 @@ local function IsFaceZOutOfRange ( vtNFace, Tool)
end
local function GetCorrectedElevationDownUp( )
-- TODO da fare
local function GetCorrectedElevationDownUp( Face, Edge, b3Raw )
end
local function IsOrientationOkForDownUp( Face, Edge, b3Raw)
-- se l'utensile lavora perpendicolarmente, l'orientamento è sempre valido per DownUp
if AreSameVectorApprox( Face.vtN, Edge) then
@@ -224,12 +226,13 @@ local function IsOrientationOkForDownUp( Face, Edge, b3Raw)
end
-- orientamento 2d: si determinano il piano della faccia e la direzione perpendicolare
local sPlane = FaceOrientation[1].sPlane
local vtPerpendicularToPlane
if FaceOrientation[1].sPlane == 'XY' then
if sPlane == 'XY' then
vtPerpendicularToPlane = Z_AX()
elseif FaceOrientation[1].sPlane == 'XZ' then
elseif sPlane == 'XZ' then
vtPerpendicularToPlane = Y_AX()
elseif FaceOrientation[1].sPlane == 'YZ' then
elseif sPlane == 'YZ' then
vtPerpendicularToPlane = X_AX()
end
@@ -239,104 +242,50 @@ local function IsOrientationOkForDownUp( Face, Edge, b3Raw)
return true
end
-- orientamento composito faccia / direzione utensile
-- TODO migliorare!!
local bIsOrientationOkForDownUp = false
local _, ptOnBox = EgtSurfTmFacetOppositeSide( Face.idTrimesh, Face.id, -Edge.vtN, GDB_ID.ROOT)
-- se tutte le condizioni precedenti sono soddisfatte, il DownUp si può fare se lungo l'asse in cui Face.vtN e Edge.vtN sono discordi il punto iniziale del lato è sul box
-- in pratica, ciò significa che il braccio non entrerà in collisione con la trave
-- TODO in realtà così si escludono dei casi di faccia non troncante in cui aumenterebbe l'elevation ma si potrebbe comunque lavorare
local _, ptOnBox = EgtSurfTmFacetOppositeSide( Face.idTrimesh, Face.id, -Edge.vtN, GDB_ID.ROOT)
-- Helper function: verifica se i vettori sono discordi lungo l'asse indicato e, se sì, se il punto iniziale della lavorazione è sul box oppure no, nella direzione dell'utensile
local function IsDiscordantAndOnBox( sAxis)
-- si compongono i metodi getX, getY, getZ in base all'asse in arrivo (Face.vtN[getX] equivale a Face.vtN:getX())
local dFaceComponent = Face.vtN["get" .. sAxis](Face.vtN)
local dEdgeComponent = Edge.vtN["get" .. sAxis](Edge.vtN)
local dPtonboxComponent = ptOnBox["get" .. sAxis](ptOnBox)
local dMaxb3rawComponent = b3Raw:getMax()["get" .. sAxis](b3Raw:getMax())
local dMinb3rawComponent = b3Raw:getMin()["get" .. sAxis](b3Raw:getMin())
if FaceOrientation[1].sPlane == 'XY' then
-- X discorde
if Face.vtN:getX() * Edge.vtN:getX() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getX() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getX() > b3Raw:getMax():getX() - 500 * GEO.EPS_SMALL
if dFaceComponent * dEdgeComponent < 10 * GEO.EPS_SMALL then
if dEdgeComponent > GEO.EPS_SMALL then
return dPtonboxComponent > dMaxb3rawComponent - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getX() < b3Raw:getMax():getX() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
end
-- Y discorde
elseif Face.vtN:getY() * Edge.vtN:getY() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getY() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getY() > b3Raw:getMax():getY() - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getY() < b3Raw:getMax():getY() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
return dPtonboxComponent < dMinb3rawComponent + 500 * GEO.EPS_SMALL
end
end
elseif FaceOrientation[1].sPlane == 'XZ' then
-- X discorde
if Face.vtN:getX() * Edge.vtN:getX() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getX() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getX() > b3Raw:getMax():getX() - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getX() < b3Raw:getMax():getX() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
end
-- Z discorde
elseif Face.vtN:getZ() * Edge.vtN:getZ() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getZ() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getZ() > b3Raw:getMax():getZ() - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getZ() < b3Raw:getMax():getZ() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
end
return false
end
-- in base all'orientamento, si verifica se il DownUp è fattibile
if sPlane == 'XY' then
if IsDiscordantAndOnBox( "X") then
return true
elseif IsDiscordantAndOnBox( "Y") then
return true
end
elseif FaceOrientation[1].sPlane == 'YZ' then
-- Y discorde
if Face.vtN:getY() * Edge.vtN:getY() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getY() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getY() > b3Raw:getMax():getY() - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getY() < b3Raw:getMax():getY() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
end
-- Z discorde
elseif Face.vtN:getZ() * Edge.vtN:getZ() < 10 * GEO.EPS_SMALL then
local bIsPointOnBox = false
if Edge.vtN:getZ() > GEO.EPS_SMALL then
bIsPointOnBox = ptOnBox:getZ() > b3Raw:getMax():getZ() - 500 * GEO.EPS_SMALL
else
bIsPointOnBox = ptOnBox:getZ() < b3Raw:getMax():getZ() + 500 * GEO.EPS_SMALL
end
if bIsPointOnBox then
bIsOrientationOkForDownUp = true
end
elseif sPlane == 'XZ' then
if IsDiscordantAndOnBox( "X") then
return true
elseif IsDiscordantAndOnBox( "Z") then
return true
end
elseif sPlane == 'YZ' then
if IsDiscordantAndOnBox( "Y") then
return true
elseif IsDiscordantAndOnBox( "Z") then
return true
end
end
return false
end