Modificato split a griglia
This commit is contained in:
+6
-5
@@ -15,7 +15,7 @@
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
EgtEnableDebug( false)
|
||||
-- EgtEnableDebug( false)
|
||||
|
||||
-- Imposto direttorio per librerie
|
||||
@@ -69,12 +69,13 @@ local vSashJoints = { SashJointType, SashJointType, SashJointType, SashJointType
|
||||
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.ROUND_ARC, vFrameJoints, WindowWidth, WindowHeight)
|
||||
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.SEGMENTAL_ARC, { FrameJointType, FrameJointType, FrameJointType, FrameJointType}, 1500, 1800, 2200)
|
||||
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.CHAMFER, { FrameJointType, FrameJointType, FrameJointType, FrameJointType, FrameJointType}, WindowWidth, WindowHeight, WindowHeight + 500)
|
||||
local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.POINTED_ARC, { FrameJointType, FrameJointType, FrameJointType, FrameJointType, FrameJointType}, 900, 1500, 2100)
|
||||
-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.POINTED_ARC, { FrameJointType, FrameJointType, FrameJointType, FrameJointType, FrameJointType}, 900, 1500, 2100)
|
||||
local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPES.POINTED_ARC, { FrameJointType, FrameJointType, FrameJointType, FrameJointType, FrameJointType}, 1500, 1500, 2400)
|
||||
|
||||
------------------------ Aggiunta split a griglia ------------------------
|
||||
WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.ABSOLUT, {100, 300, 100, 300}, {500, 600, 850}, false)
|
||||
-- WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.PERCENTAGE, {0.33, 0.33}, {0.3, 0.3}, true)
|
||||
-- WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.PROPORTIONAL, {2, 1, 1, 1}, {1, 2, 1, 2, 1}, true)
|
||||
-- WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.ABSOLUT, {100, 300, 100, 300}, {500, 600, 850}, false)
|
||||
-- WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.PERCENTAGE, {0.15}, {0.5, 0.45}, false)
|
||||
WinCreate.AddGridSplits( nFrameId, WIN_MEASURE.PROPORTIONAL, {1, 4, 1, 2, 1}, {1, 2, 1, 2, 1}, false)
|
||||
|
||||
------------------------ Cambi profilo ------------------------
|
||||
-- vetro/anta
|
||||
|
||||
@@ -66,7 +66,7 @@ end
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea le curve che definiscono il telaio in base alla geometria richiesta
|
||||
local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
|
||||
|
||||
-- rettangolo
|
||||
if nType == WIN_FRAME_TYPES.RECT then
|
||||
-- telaio rettangolare
|
||||
@@ -79,7 +79,7 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- lato top inclinato
|
||||
-- lato top inclinato
|
||||
elseif nType == WIN_FRAME_TYPES.CHAMFER_SIDE then
|
||||
-- dHeight è l'altezza del lato sx, dVal è l'altezza del lato dx
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -90,8 +90,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
EgtSetName( nTopId, WIN_TOP)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- triangular arch
|
||||
|
||||
-- triangular arch
|
||||
elseif nType == WIN_FRAME_TYPES.CHAMFER then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -104,8 +104,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
EgtSetName( nTop2Id, WIN_TOP)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco a tutto sesto
|
||||
|
||||
-- arco a tutto sesto
|
||||
elseif nType == WIN_FRAME_TYPES.ROUND_ARC then
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nBottomId, WIN_BOTTOM)
|
||||
@@ -115,8 +115,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
EgtSetName( nTopId, WIN_TOP)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight - 0.5 * dWidth, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco ribassato
|
||||
|
||||
-- arco ribassato
|
||||
elseif nType == WIN_FRAME_TYPES.SEGMENTAL_ARC then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
@@ -127,8 +127,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
EgtSetName( nTopId, WIN_TOP)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- arco a tutto sesto
|
||||
|
||||
-- arco a tutto sesto
|
||||
elseif nType == WIN_FRAME_TYPES.POINTED_ARC then
|
||||
-- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra
|
||||
-- verifico che le due altezze abbiano valori sensati per realizzare i due archi
|
||||
@@ -146,8 +146,8 @@ local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal)
|
||||
EgtSetName( nTop2Id, WIN_TOP)
|
||||
local nLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), ORIG())
|
||||
EgtSetName( nLeftId, WIN_LEFT)
|
||||
|
||||
-- triangolo
|
||||
|
||||
-- triangolo
|
||||
elseif nType == WIN_FRAME_TYPES.TRG then
|
||||
local nBottomId = EgtLine( nLayerId, ORIG(), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nBottomId, WIN_BOTTOM)
|
||||
@@ -170,14 +170,14 @@ end
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea il telaio a partire da una specifica geometria ( rettangolo, chamfer...)
|
||||
function WinCreate.CreateFrame( nType, vJoints, dWidth, dHeight, dHeight2)
|
||||
|
||||
|
||||
-- creo gruppo per telaio
|
||||
local nAreaId = EgtGroup( GDB_ID.ROOT)
|
||||
EgtSetName( nAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')')
|
||||
EgtSetLevel( nAreaId, GDB_LV.SYSTEM)
|
||||
-- imposto il tipo
|
||||
-- imposto il tipo
|
||||
EgtSetInfo( nAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME)
|
||||
|
||||
|
||||
-- costruisco le curve di outline
|
||||
local nOutlineLayerId = EgtGroup( nAreaId)
|
||||
EgtSetName( nOutlineLayerId, WIN_AREAOUTLINE)
|
||||
@@ -185,7 +185,7 @@ function WinCreate.CreateFrame( nType, vJoints, dWidth, dHeight, dHeight2)
|
||||
EgtSetInfo( nAreaId, WIN_FRAME_TYPE, nType)
|
||||
-- imposto tipo giunzioni
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINTS, vJoints)
|
||||
|
||||
|
||||
return nAreaId
|
||||
end
|
||||
|
||||
@@ -376,6 +376,10 @@ end
|
||||
-- funzione che crea tagli split grid
|
||||
function WinCreate.AddGridSplits( nAreaLayerId, MeasureType, PositionListVert, PositionListHoriz, bStartVertical, nSplitType)
|
||||
local AreaResult = {}
|
||||
-- recupero contorno area precedente
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
-- calcolo numero parti totali nel caso di misura proporzionale
|
||||
local nProportionVert = 0
|
||||
local nProportionHoriz = 0
|
||||
if MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
@@ -386,27 +390,24 @@ function WinCreate.AddGridSplits( nAreaLayerId, MeasureType, PositionListVert, P
|
||||
nProportionHoriz = nProportionHoriz + PositionListHoriz[i]
|
||||
end
|
||||
end
|
||||
-- recupero contorno area precedente
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
-- calcolo gli split nella direzione secondaria
|
||||
local PositionAbs = {}
|
||||
local PositionList = EgtIf( bStartVertical, PositionListHoriz, PositionListVert)
|
||||
local nProportion = EgtIf( bStartVertical, nProportionHoriz, nProportionVert)
|
||||
local dDim = EgtIf( bStartVertical, b3OutlineLayer:getDimY(), b3OutlineLayer:getDimX())
|
||||
for i = 1, #PositionList do
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
PositionAbs[i] = PositionList[i]
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
PositionAbs[i] = dDim / nProportion * PositionList[i]
|
||||
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
||||
PositionAbs[i] = dDim * PositionList[i]
|
||||
end
|
||||
end
|
||||
if bStartVertical then
|
||||
local AreaList = WinCreate.AddSplits( nAreaLayerId, WIN_SPLITORIENTATION.VERTICAL, MeasureType, PositionListVert, nProportionVert, nSplitType)
|
||||
-- calcolo gli split orizzontali
|
||||
local HorizAbs = {}
|
||||
local dPositionCum = 0
|
||||
for i = 1, #PositionListHoriz do
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
HorizAbs[i] = PositionListHoriz[i]
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
--HorizAbs[i] = b3OutlineLayer:getDimY() / ( nProportionHoriz - dPositionCum) * PositionListHoriz[i]
|
||||
HorizAbs[i] = b3OutlineLayer:getDimY() / nProportionHoriz * PositionListHoriz[i]
|
||||
--dPositionCum = dPositionCum + PositionListHoriz[i]
|
||||
elseif MeasureType == WIN_MEASURE.PERCENTAGE then
|
||||
HorizAbs[i] = b3OutlineLayer:getDimY() * PositionListHoriz[i]
|
||||
end
|
||||
end
|
||||
for i = 1, #AreaList do
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, HorizAbs, nProportionHoriz, nSplitType) or {}
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, PositionAbs, nProportionHoriz, nSplitType) or {}
|
||||
for j = 1, #AreaTemp do
|
||||
table.insert( AreaResult, AreaTemp[j])
|
||||
end
|
||||
@@ -419,21 +420,21 @@ function WinCreate.AddGridSplits( nAreaLayerId, MeasureType, PositionListVert, P
|
||||
local b3CurrentOutlineLayer = EgtGetBBox( nCurrentOutlineLayerId, GDB_BB.STANDARD)
|
||||
local dDiff = b3OutlineLayer:getMin():getX() - b3CurrentOutlineLayer:getMin():getX()
|
||||
if dDiff < - GEO.EPS_SMALL then
|
||||
local nFirstIndex = #PositionListVert + 1
|
||||
for k = 1, #PositionListVert do
|
||||
if PositionListVert[k] + dDiff > GEO.EPS_SMALL then
|
||||
PositionListVert[k] = PositionListVert[k] + dDiff
|
||||
local nFirstIndex = #PositionAbs + 1
|
||||
for k = 1, #PositionAbs do
|
||||
if PositionAbs[k] + dDiff > GEO.EPS_SMALL then
|
||||
PositionAbs[k] = PositionAbs[k] + dDiff
|
||||
nFirstIndex = k
|
||||
break
|
||||
elseif k ~= #PositionListVert then
|
||||
PositionListVert[k + 1] = PositionListVert[k] + PositionListVert[k + 1]
|
||||
elseif k ~= #PositionAbs then
|
||||
PositionAbs[k + 1] = PositionAbs[k] + PositionAbs[k + 1]
|
||||
end
|
||||
end
|
||||
for k = 1, nFirstIndex - 1 do
|
||||
table.remove( PositionListVert, 1)
|
||||
table.remove( PositionAbs, 1)
|
||||
end
|
||||
end
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.VERTICAL, MeasureType, PositionListVert, nProportionVert, nSplitType) or {}
|
||||
local AreaTemp = WinCreate.AddSplits( AreaList[i], WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, PositionAbs, nProportionVert, nSplitType) or {}
|
||||
for j = 1, #AreaTemp do
|
||||
table.insert( AreaResult, AreaTemp[j])
|
||||
end
|
||||
@@ -445,7 +446,7 @@ end
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che assegna il nome alla curva di split nella sottoarea in base alla sua direzione
|
||||
local function SetSplitName( nSplitId)
|
||||
|
||||
|
||||
local vtMedia = ( ( EgtEV( nSplitId) - EgtSV( nSplitId)) / 2)
|
||||
if not vtMedia:normalize() then
|
||||
vtMedia = EgtSV( nSplitId)
|
||||
@@ -468,7 +469,7 @@ end
|
||||
----------------------------------------------------------------------------------
|
||||
-- funzione che crea le aree da un taglio split
|
||||
local function CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2, vOutlineCrvs)
|
||||
|
||||
|
||||
-- creo layer per le due sottoaree
|
||||
local nArea1Id = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nArea1Id , WIN_AREA .. '1')
|
||||
@@ -480,13 +481,13 @@ local function CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2
|
||||
EgtSetInfo( nArea2Id, WIN_AREATYPE, WIN_AREATYPES.NULL)
|
||||
local nArea2OutlineLayerId = EgtGroup( nArea2Id)
|
||||
EgtSetName( nArea2OutlineLayerId , WIN_AREAOUTLINE)
|
||||
|
||||
|
||||
-- ad ogni sottoarea associo la porzione di curva composita corrispondente
|
||||
local nCrv1 = EgtCopyGlob( nCompo, nArea1OutlineLayerId)
|
||||
local nCrv2 = EgtCopyGlob( nCompo, nArea2OutlineLayerId)
|
||||
EgtTrimCurveStartEndAtParam( nCrv1, dPar2, dPar1)
|
||||
EgtTrimCurveStartEndAtParam( nCrv2, dPar1, dPar2)
|
||||
|
||||
|
||||
-- copio curva di split
|
||||
local nSplitId1 = EgtCopyGlob( nSplitId, nArea1OutlineLayerId)
|
||||
local nSplitId2 = EgtCopyGlob( nSplitId, nArea2OutlineLayerId)
|
||||
@@ -541,7 +542,7 @@ local function CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2
|
||||
nFirstInAreaId = EgtGetFirstInGroup( nArea2OutlineLayerId)
|
||||
sFirstInAreaName = EgtGetName( nFirstInAreaId)
|
||||
end
|
||||
|
||||
|
||||
return nArea1Id, nArea2Id
|
||||
end
|
||||
|
||||
@@ -560,7 +561,7 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
EgtRelocateGlob( nSplitId, nSplitLayerId)
|
||||
-- assegno nome profilo
|
||||
EgtSetName( nSplitId, WIN_SPLIT)
|
||||
|
||||
|
||||
-- verifico se devo impostare tipo di split ( solo se deriva da tipo frame)
|
||||
if nSplitType then
|
||||
local nParentAreaId = nAreaLayerId
|
||||
@@ -575,7 +576,7 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
EgtSetInfo( nSplitLayerId, WIN_SPLITTYPE, nSplitType)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Ricerca delle intersezioni :
|
||||
-- creo una curva composita a partire da tutte le curve di outline
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
@@ -594,14 +595,14 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
local pt1 = EgtSP( nFirst)
|
||||
local pt2 = EgtSP( nFirst + 1)
|
||||
EgtErase( { nFirst, nFirst + 1})
|
||||
|
||||
|
||||
-- recupero i parametri di intersezione sulla curva di split
|
||||
local dSplitParS = EgtCurveParamAtPoint( nSplitId, pt1, 100 * GEO.EPS_SMALL)
|
||||
local dSplitParE = EgtCurveParamAtPoint( nSplitId, pt2, 100 * GEO.EPS_SMALL)
|
||||
-- recupero i parametri di intersezione sulla curva composita
|
||||
local dPar1 = EgtCurveParamAtPoint( nCompo, pt1, 100 * GEO.EPS_SMALL)
|
||||
local dPar2 = EgtCurveParamAtPoint( nCompo, pt2, 100 * GEO.EPS_SMALL)
|
||||
|
||||
|
||||
-- ricavo i parametri di intersezione legati a start ed end dello split
|
||||
local dParCrvS = dPar1
|
||||
local dParCrvE = dPar2
|
||||
@@ -609,10 +610,10 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
dSplitParS, dSplitParE = dSplitParE, dSplitParS
|
||||
dParCrvS, dParCrvE = dParCrvE, dParCrvS
|
||||
end
|
||||
|
||||
|
||||
-- taglio la curva di split nei punti di intersezione
|
||||
EgtTrimCurveStartEndAtParam( nSplitId, dSplitParS, dSplitParE)
|
||||
|
||||
|
||||
-- setto info per intersezione start
|
||||
-- se il parametro è intero allora l'intersezione coinvolge due curve successive
|
||||
if abs( dParCrvS - ceil( dParCrvS)) < GEO.EPS_SMALL then
|
||||
@@ -628,7 +629,7 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
local nCrv = vOutlineCrvs[ floor( dParCrvS) + 1]
|
||||
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { nCrv})
|
||||
end
|
||||
|
||||
|
||||
-- setto info per intersezione end
|
||||
if abs( dParCrvE - ceil( dParCrvE)) < GEO.EPS_SMALL then
|
||||
local nCrv = vOutlineCrvs[ ceil( dParCrvE) + 1]
|
||||
@@ -645,11 +646,11 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType)
|
||||
|
||||
-- creo sottoaree
|
||||
local nArea1, nArea2 = CreateAreaFromSplit( nAreaLayerId, nCompo, nSplitId, dPar1, dPar2, vOutlineCrvs)
|
||||
|
||||
|
||||
EgtErase( nCompo)
|
||||
|
||||
|
||||
return nArea1, nArea2
|
||||
|
||||
|
||||
end
|
||||
|
||||
----------------------------------------------------------------------------------
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
EgtEnableDebug( false)
|
||||
|
||||
-- Imposto direttorio per librerie
|
||||
local sBaseDir = EgtGetSourceDir()
|
||||
|
||||
Reference in New Issue
Block a user