3dPrinting :

- modificata definizione e gestione delle partenze sui layer.
This commit is contained in:
SaraP
2022-07-15 17:26:52 +02:00
parent 5c2a0d1caa
commit 7f47280495
5 changed files with 85 additions and 51 deletions
+58 -22
View File
@@ -31,24 +31,44 @@ local function GetLayerParamsForPathCalc()
end
---------------------------------------------------------------------
local function GetLayerStartPoint( nLayId)
local function GetLayerStartPoint( nLayId, vtSlicing)
local ptStart
-- recupero il punto di partenza usato nel layer precedente
local nPrev = EgtGetPrev( nLayId)
local nCrvGrp = EgtGetFirstNameInGroup( nPrev, CONTOUR_GRP..'*')
local nPathGrp = EgtGetFirstNameInGroup( nCrvGrp, PATH_GRP)
local nCrv = EgtGetFirstInGroup( nPathGrp)
if nCrv then
ptStart = EgtSP( nCrv, GDB_ID.ROOT)
else
ptStart = EgtGetInfo( s_nPartId, KEY_START_POINT, 'p')
end
return ptStart
-- recupero quota layer
local dZ = EgtGetInfo( nLayId, KEY_SLICE_REAL_Z, 'd')
local dDeltaZ = EgtGetInfo( nLayId, KEY_SLICE_DELTAZ, 'd')
local frSlicing = Frame3d( ORIG(), vtSlicing)
local ptOn = Point3d( 0, 0, dZ + dDeltaZ)
ptOn:toGlob( frSlicing)
-- gruppo temporaneo dove salvo i risultati
local nGrpTmp = EgtGroup( nLayId)
local vPtStart = {}
local nAuxGrp = EgtGetFirstNameInGroup( s_nPartId, LAY_AUX)
local nStartId = EgtGetFirstNameInGroup( nAuxGrp, START_GEOM)
while nStartId do
local nType = EgtGetType( nStartId)
-- se punto
if nType == GDB_TY.GEO_POINT then
table.insert( vPtStart, EgtSP( nStartId))
else
-- se curva interseco con il piano
local nId, nCnt = EgtPlaneCurveInters( ptOn, vtSlicing, nStartId, nGrpTmp, GDB_RT.GLOB)
if nId then
for i = nId, nId + nCnt - 1 do
table.insert( vPtStart, EgtSP( i))
end
end
end
nStartId = EgtGetNextName( nStartId, START_GEOM)
end
EgtErase( nGrpTmp)
return vPtStart
end
---------------------------------------------------------------------
local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, nLayId)
local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, vPtStart)
local nChunks = EgtSurfFrChunkCount( nSrfId)
for nC = 0, nChunks - 1 do
@@ -71,11 +91,24 @@ local function GetPathsFromSurf( nSrfId, sName, nType, nGrpId, nLayId)
return
end
-- scelta start point
local ptStart = GetLayerStartPoint( nLayId)
EgtChangeClosedCurveStartPoint( nCrvId + nInd, ptStart, GDB_RT.GLOB)
end
end
-- cerco lo start point più vicino tra quelli possibili
if vPtStart and #vPtStart > 0 then
local nMinIdx = -1
local dMinDist = GEO.INFINITO
for i = 1, #vPtStart do
local dDist = EgtPointCurveDist( vPtStart[i], nCrvId + nInd)
if dDist < dMinDist - 10 * GEO.EPS_SMALL then
dMinDist = dDist
nMinIdx = i
end
end
EgtChangeClosedCurveStartPoint( nCrvId + nInd, vPtStart[nMinIdx])
else
-- se non ci sono start point disponibili prendo l'origine
EgtChangeClosedCurveStartPoint( nCrvId + nInd, Point3d( 0, 0, 0), GDB_RT.GLOB)
end
end
end
end
--------------------------------------------------------------------
@@ -474,7 +507,10 @@ function CalcPaths.Exec( nPartId, nStmId)
for nIdx = 1, #vLayIds do
local nRibsGrp = EgtGetFirstNameInGroup( vLayIds[nIdx], RIBS_GRP)
-- recupero gli start point per il layer
local vPtStart = GetLayerStartPoint( vLayIds[nIdx], LayerParams.vtSlicing)
-- scorro tutti i gruppi di contorni
local nCrvGrpId = EgtGetFirstNameInGroup( vLayIds[nIdx], CONTOUR_GRP.."*") or GDB_ID.NULL
while nCrvGrpId ~= GDB_ID.NULL do
@@ -514,7 +550,7 @@ function CalcPaths.Exec( nPartId, nStmId)
elseif not bExists then
EgtOutLog( 'Warning : ExtOffset not possible (layer '..tostring( nIdx)..') - CalcPaths')
else
GetPathsFromSurf( nSrfId, SHELL_CRV..'0', TYPE.OUTER_SHELL, nGrpId, vLayIds[nIdx])
GetPathsFromSurf( nSrfId, SHELL_CRV..'0', TYPE.OUTER_SHELL, nGrpId, vPtStart)
end
EgtErase( nSrfId)
@@ -536,7 +572,7 @@ function CalcPaths.Exec( nPartId, nStmId)
elseif not bExists then
EgtOutLog( 'Warning : IntOffset not possible (layer '..tostring( nIdx)..') - CalcPaths')
else
GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, vLayIds[nIdx])
GetPathsFromSurf( nSrfId, SHELL_CRV..tostring( nInd2), TYPE.INNER_SHELL, nGrpId, vPtStart)
end
EgtErase( nSrfId)
end