Primo commit:
- progettazione serramenti rettangolari , ad arco e di forma generica - gestione vetrifissi, ante, divisioni, montanti, ante battenti e riceventi - costruzione solidi - scrittura e lettura file jwd - inizio creazione test - inizio gestione spine
This commit is contained in:
@@ -0,0 +1,958 @@
|
||||
--
|
||||
-- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT
|
||||
-- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEE GGGG TTTT
|
||||
-- EEEEEEE GGGG GGGGGGG TTTT
|
||||
-- EEEEEEE GGGG GGGGGGG TTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEEEEEEEE GGGGGGGGGG TTTT
|
||||
-- EEEEEEEEEE GGGGGG TTTT
|
||||
--
|
||||
-- by Egalware s.r.l.
|
||||
-- Window project software by Egalware s.r.l. 2023/05/02
|
||||
|
||||
-- Tabella per definizione modulo
|
||||
local WinLib = {}
|
||||
|
||||
-- Include
|
||||
require( 'EgtBase')
|
||||
_G.package.loaded.WinConst = nil
|
||||
require( 'WinConst')
|
||||
|
||||
-- funzioni
|
||||
|
||||
-- funzione che crea il buco per la finestra
|
||||
function WinLib.CreateHole( dWidth, dHeight)
|
||||
-- creo gruppo per buco
|
||||
local nAreaLayerId = EgtGroup( GDB_ID.ROOT)
|
||||
EgtSetName( nAreaLayerId, WIN_FRAME)
|
||||
local nAreaOutlineLayerId = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE)
|
||||
-- disegno outline
|
||||
local nHoleBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nHoleBottomId, WIN_BOTTOM)
|
||||
local nHoleRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
|
||||
EgtSetName( nHoleRightId, WIN_RIGHT)
|
||||
local nHoleTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
|
||||
EgtSetName( nHoleTopId, WIN_TOP)
|
||||
local nHoleLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
|
||||
EgtSetName( nHoleLeftId, WIN_LEFT)
|
||||
return nAreaLayerId
|
||||
end
|
||||
|
||||
-- funzione che crea il telaio a partire dal buco
|
||||
function WinLib.CreateFrameOnHole( nHoleLayerId, dWidth, dHeight)
|
||||
local nAreaOutlineLayerId = EgtGroup( nHoleLayerId)
|
||||
EgtSetName( nAreaOutlineLayerId, WIN_OUTLINE)
|
||||
-- disegno outline
|
||||
local nHoleBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0))
|
||||
EgtSetName( nHoleBottomId, WIN_BOTTOM)
|
||||
local nHoleRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0))
|
||||
EgtSetName( nHoleRightId, WIN_RIGHT)
|
||||
local nHoleTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0))
|
||||
EgtSetName( nHoleTopId, WIN_TOP)
|
||||
local nHoleLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0))
|
||||
EgtSetName( nHoleLeftId, WIN_LEFT)
|
||||
end
|
||||
|
||||
-- funzione che crea il telaio a partire dal buco
|
||||
function WinLib.CreateFrameAsHole( nAreaLayerId, JointType)
|
||||
-- creo layer outline del frame
|
||||
local nOutlineLayerId = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nOutlineLayerId, WIN_OUTLINE)
|
||||
-- recupero outline del buco
|
||||
local nAreaOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
-- lo copio
|
||||
local nHoleOutlineId = EgtGetFirstInGroup( nAreaOutlineLayerId)
|
||||
while nHoleOutlineId do
|
||||
local nOutlineId = EgtCopy( nHoleOutlineId, nOutlineLayerId)
|
||||
-- da modificare!!!
|
||||
-- funzione che assegna i profili serramento ai vari outline
|
||||
local sName = EgtGetName( nHoleOutlineId)
|
||||
if sName == WIN_BOTTOM then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_BOTTOM)
|
||||
elseif sName == WIN_RIGHT then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_TOP)
|
||||
elseif sName == WIN_TOP then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_TOP)
|
||||
elseif sName == WIN_LEFT then
|
||||
EgtSetInfo( nOutlineId, WIN_PROFILETYPE, WIN_SASH_TOP)
|
||||
end
|
||||
nHoleOutlineId = EgtGetNext( nHoleOutlineId)
|
||||
end
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINT_BL, JointType)
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINT_BR, JointType)
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINT_TL, JointType)
|
||||
EgtSetInfo( nOutlineLayerId, WIN_JOINT_TR, JointType)
|
||||
end
|
||||
|
||||
-- funzione che aggiunge una anta
|
||||
function WinLib.AddSash( nAreaId)
|
||||
-- creo nuova area
|
||||
local nSashAreaId = EgtGroup( nAreaId)
|
||||
EgtSetName( nSashAreaId, WIN_SASH)
|
||||
EgtSetInfo( nSashAreaId, WIN_AREATYPE, WIN_AREATYPES.SASH)
|
||||
-- recupero outline area precedente
|
||||
local nPrevAreaOutlineId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
||||
-- lo copio per outline area dell'anta
|
||||
local nAreaOutlineId = EgtCopy( nPrevAreaOutlineId, nSashAreaId)
|
||||
return nSashAreaId
|
||||
end
|
||||
|
||||
-- funzione che aggiunge un riempimento
|
||||
function WinLib.AddFill( nAreaId, FillType)
|
||||
-- creo nuova area
|
||||
local nFillAreaId = EgtGroup( nAreaId)
|
||||
EgtSetName( nFillAreaId, WIN_FILL)
|
||||
EgtSetInfo( nFillAreaId, WIN_AREATYPE, WIN_AREATYPES.FILL)
|
||||
-- recupero outline area precedente
|
||||
local nPrevAreaOutlineId = EgtGetFirstNameInGroup( nAreaId, WIN_AREAOUTLINE)
|
||||
-- lo copio per outline area dell'anta
|
||||
local nAreaOutlineId = EgtCopy( nPrevAreaOutlineId, nFillAreaId)
|
||||
-- imposto tipo di fill
|
||||
EgtSetInfo( nFillAreaId, WIN_FILLTYPE, FillType)
|
||||
return nFillAreaId
|
||||
end
|
||||
|
||||
-- funzione che restituisce un outline dato un pezzo
|
||||
function WinLib.GetOutlineFromPart( nPartId)
|
||||
local nAreaId = EgtGetInfo( nPartId, WIN_AREA)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE)
|
||||
local sName = EgtGetName( nPartId)
|
||||
return EgtGetFirstNameInGroup( nOutlineLayerId, sName)
|
||||
end
|
||||
|
||||
-- funzione che crea un taglio split
|
||||
function WinLib.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion)
|
||||
-- creo layer per split
|
||||
local nSplitLayerId = EgtGroup( nAreaLayerId)
|
||||
EgtSetName( nSplitLayerId, WIN_SPLIT)
|
||||
-- recupero contorno area precedente
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_AREAOUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
local OutlineIds = {}
|
||||
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
while nOutlineId do
|
||||
local sName = EgtGetName( nOutlineId)
|
||||
table.insert( OutlineIds, nOutlineId)
|
||||
nOutlineId = EgtGetNext( nOutlineId)
|
||||
end
|
||||
local nSplitId
|
||||
if SplitType == WIN_SPLITTYPE.VERTICAL then
|
||||
-- creo linea
|
||||
local nCalcPosition = 0
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
nCalcPosition = nPosition
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
nCalcPosition = b3OutlineLayer:getDimX() / nProportion * nPosition
|
||||
end
|
||||
local nTotSplitId = EgtLine( nSplitLayerId, Point3d( nCalcPosition, 0, 0), Point3d( nCalcPosition, b3OutlineLayer:getDimY(), 0))
|
||||
-- la taglio con i contorni
|
||||
local nCompoOutlineId = EgtCurveCompo( nSplitLayerId, OutlineIds, false)
|
||||
local nFROutlineId = EgtSurfFlatRegion( nSplitLayerId, nCompoOutlineId)
|
||||
nSplitId = EgtTrimCurveWithRegion( nTotSplitId, nFROutlineId, true, false)
|
||||
EgtSetName( nSplitId, WIN_VERTICAL)
|
||||
EgtErase( { nCompoOutlineId, nFROutlineId})
|
||||
EgtSetInfo( nSplitId, WIN_PROFILETYPE, WIN_SASH_VERTICAL)
|
||||
elseif SplitType == WIN_SPLITTYPE.HORIZONTAL then
|
||||
-- creo linea
|
||||
local nCalcPosition = 0
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
nCalcPosition = nPosition
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
nCalcPosition = b3OutlineLayer:getDimY() / nProportion * nPosition
|
||||
end
|
||||
local nTotSplitId = EgtLine( nSplitLayerId, Point3d( 0, nCalcPosition, 0), Point3d( b3OutlineLayer:getDimX(), nCalcPosition, 0))
|
||||
-- la taglio con i contorni
|
||||
local nCompoOutlineId = EgtCurveCompo( nSplitLayerId, OutlineIds, false)
|
||||
local nFROutlineId = EgtSurfFlatRegion( nSplitLayerId, nCompoOutlineId)
|
||||
nSplitId = EgtTrimCurveWithRegion( nTotSplitId, nFROutlineId, true, false)
|
||||
EgtSetName( nSplitId, WIN_HORIZONTAL)
|
||||
EgtErase( { nCompoOutlineId, nFROutlineId})
|
||||
EgtSetInfo( nSplitId, WIN_PROFILETYPE, WIN_SASH_HORIZONTAL)
|
||||
end
|
||||
-- creo aree
|
||||
WinLib.CreateAreaFromSplit( nAreaLayerId, nSplitId)
|
||||
end
|
||||
|
||||
-- funzione che crea tagli split multipli
|
||||
function WinLib.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion)
|
||||
if MeasureType == WIN_MEASURE.ABSOLUT then
|
||||
for nIndex = 1, #PositionList do
|
||||
WinLib.AddSplit( nAreaLayerId, SplitType, MeasureType, PositionList[nIndex], nProportion)
|
||||
end
|
||||
elseif MeasureType == WIN_MEASURE.PROPORTIONAL then
|
||||
for nIndex = 1, #PositionList do
|
||||
WinLib.AddSplit( nAreaLayerId, SplitType, MeasureType, PositionList[nIndex], nProportion)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- funzione che crea un taglio split da una curva generica
|
||||
function WinLib.AddGenSplit( nAreaLayerId, nSplitId)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_OUTLINE)
|
||||
local b3OutlineLayer = EgtGetBBox( nOutlineLayerId, GDB_BB.STANDARD)
|
||||
-- allungo curva split per cercare intersezioni
|
||||
EgtExtendCurveStartByLen( nSplitId, 10)
|
||||
EgtExtendCurveEndByLen( nSplitId, 10)
|
||||
-- recupero lista intersezioni
|
||||
local OutlineInters = {}
|
||||
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
while nOutlineId do
|
||||
local sName = EgtGetName( nOutlineId)
|
||||
-- verifico se ci siano intersezioni con questo outline
|
||||
local ptInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId))
|
||||
if ptInters then
|
||||
table.insert( OutlineInters, { Id = nOutlineId, IntersPoint = ptInters})
|
||||
end
|
||||
nOutlineId = EgtGetNext( nOutlineId)
|
||||
end
|
||||
local ptStartSplit = EgtSP( nSplitId)
|
||||
local ptEndSplit = EgtEP( nSplitId)
|
||||
local StartInters
|
||||
local EndInters
|
||||
for nIndex = 1, #OutlineInters do
|
||||
local CurrOutInters = OutlineInters[nIndex]
|
||||
CurrOutInters.StartDistance = (CurrOutInters.IntersPoint - ptStartSplit):sqlen()
|
||||
CurrOutInters.EndDistance = (CurrOutInters.IntersPoint - ptEndSplit):sqlen()
|
||||
if not StartInters or CurrOutInters.StartDistance < StartInters.StartDistance then
|
||||
StartInters = CurrOutInters
|
||||
end
|
||||
if not EndInters or CurrOutInters.EndDistance < EndInters.EndDistance then
|
||||
EndInters = CurrOutInters
|
||||
end
|
||||
end
|
||||
-- accorcio la curva split su intersezione outline
|
||||
local dStartSplitInters = EgtCurveParamAtPoint( nSplitId, StartInters.IntersPoint)
|
||||
EgtTrimCurveStartAtParam( nSplitId, dStartSplitInters)
|
||||
local dEndSplitInters = EgtCurveParamAtPoint( nSplitId, EndInters.IntersPoint)
|
||||
EgtTrimCurveEndAtParam( nSplitId, dEndSplitInters)
|
||||
EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, StartInters.Id)
|
||||
EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, EndInters.Id)
|
||||
-- assegno nome e tipo profilo
|
||||
EgtSetName( nSplitId, WIN_SPLIT)
|
||||
EgtSetInfo( nSplitId, WIN_PROFILETYPE, WIN_SASH_HORIZONTAL)
|
||||
-- creo aree
|
||||
WinLib.CreateAreaFromSplit( nAreaLayerId, nSplitId)
|
||||
end
|
||||
|
||||
-- funzione che crea tagli split da curve generiche
|
||||
function WinLib.AddGenSplits( nAreaLayerId, SplitList)
|
||||
for nIndex = 1, #SplitList do
|
||||
WinLib.AddSplit( nAreaLayerId, SplitList[nIndex])
|
||||
end
|
||||
end
|
||||
|
||||
-- funzione che crea le aree da un taglio split
|
||||
function WinLib.CreateAreaFromSplit( nAreaLayerId, nSplitId)
|
||||
-- creo layer per le due aree
|
||||
local nArea1Id = EgtGroup( nAreaLayerId)
|
||||
local nArea2Id = EgtGroup( nAreaLayerId)
|
||||
EgtSetInfo( nArea1Id, 'SOU', nSplitId)
|
||||
EgtSetName( nArea1Id , 'Area' .. 1)
|
||||
local nArea1OutlineLayerId = EgtGroup( nArea1Id)
|
||||
EgtSetName( nArea1OutlineLayerId , WIN_AREAOUTLINE)
|
||||
EgtSetInfo( nArea2Id, 'SOU', nSplitId)
|
||||
EgtSetName( nArea2Id , 'Area' .. 2)
|
||||
local nArea2OutlineLayerId = EgtGroup( nArea2Id)
|
||||
EgtSetName( nArea2OutlineLayerId , WIN_AREAOUTLINE)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_OUTLINE)
|
||||
--local Outlines = {}
|
||||
local nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
local nInters = 0
|
||||
while nOutlineId and nInters ~= 3 do
|
||||
local sName = EgtGetName( nOutlineId)
|
||||
-- calcolo intersezioni con questo outline
|
||||
local ptInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId))
|
||||
if ptInters then
|
||||
if nInters == 0 then
|
||||
-- trovato primo punto di intersezione - inizio area 2
|
||||
nInters = 1
|
||||
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
||||
local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
||||
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
|
||||
elseif nInters == 1 then
|
||||
-- trovato secondo punto di intersezione - fine area 2
|
||||
nInters = 2
|
||||
local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
||||
local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
||||
EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam)
|
||||
-- copio anche split
|
||||
local nSplitCopyId = EgtCopy( nSplitId, nArea2OutlineLayerId)
|
||||
if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then
|
||||
EgtInvertCurve( nSplitCopyId)
|
||||
end
|
||||
-- inizio area 1
|
||||
local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
||||
local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
||||
EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam)
|
||||
elseif nInters == 2 then
|
||||
-- trovato secondo punto di intersezione - fine area 1
|
||||
nInters = 3
|
||||
local nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
||||
local dEndIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters)
|
||||
EgtTrimCurveEndAtParam( nCopyId, dEndIntersParam)
|
||||
-- copio anche split
|
||||
local nSplitCopyId = EgtCopy( nSplitId, nArea1OutlineLayerId)
|
||||
if not AreSamePointExact( EgtEP( nCopyId), EgtSP( nSplitCopyId)) then
|
||||
EgtInvertCurve( nSplitCopyId)
|
||||
end
|
||||
end
|
||||
elseif nInters == 1 then
|
||||
-- copio nel profilo 2
|
||||
EgtCopy( nOutlineId, nArea2OutlineLayerId)
|
||||
elseif nInters == 2 then
|
||||
-- copio nel profilo 1
|
||||
EgtCopy( nOutlineId, nArea1OutlineLayerId)
|
||||
end
|
||||
-- aggiorno indice
|
||||
nOutlineId = EgtGetNext( nOutlineId)
|
||||
-- se arrivato alla fine riparto
|
||||
if not nOutlineId then
|
||||
nOutlineId = EgtGetFirstInGroup( nOutlineLayerId)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- funzione che restituisce BBox del Ref del profilo
|
||||
function WinLib.GetRefWithBBoxFromProfile( nProfileFrameLayerId, sProfileType)
|
||||
local nProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, sProfileType)
|
||||
local nProfileRefId = EgtGetFirstNameInGroup( nProfileId, WIN_REF)
|
||||
local b3Ref = EgtGetBBox( nProfileRefId, GDB_BB.STANDARD)
|
||||
return nProfileId, b3Ref, nProfileRefId
|
||||
end
|
||||
|
||||
-- funzione che restituisce ref e calcola delta controprofilo dal profilo passatogli
|
||||
function WinLib.GetDeltaProfile( nProfileFrameLayerId, sProfileType)
|
||||
local nProfileId, b3Ref, nProfileRefId = WinLib.GetRefWithBBoxFromProfile( nProfileFrameLayerId, sProfileType)
|
||||
local nCPId = EgtGetFirstNameInGroup( nProfileId, WIN_CTRIN)
|
||||
local b3CP = EgtGetBBox( nCPId, GDB_BB.STANDARD)
|
||||
local dCPDelta = b3Ref:getDimY() - b3CP:getDimY()
|
||||
return dCPDelta, b3Ref, nProfileId, nProfileRefId
|
||||
end
|
||||
|
||||
-- funzione che crea le curve del geo
|
||||
function WinLib.CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, StartJointType, EndJointType, nProfileType, nGeoLayerId, nProfileFrameLayerId)
|
||||
local nCurrCurveId
|
||||
local nCurrOffsetId
|
||||
local nPrevCurveId
|
||||
local nNextCurveId
|
||||
local dGeoWidth
|
||||
-- recupero ref e controprofilo e calcolo delta del top, prev e next
|
||||
local sCurrProfileType = EgtGetInfo( nOutlineId, WIN_PROFILETYPE)
|
||||
local _, b3CurrRef, nCurrProfileId, nCurrProfileRefId = WinLib.GetDeltaProfile( nProfileFrameLayerId, sCurrProfileType)
|
||||
local sPrevProfileType = EgtGetInfo( nPrevOutlineId, WIN_PROFILETYPE)
|
||||
local dPrevCPDelta, _ = WinLib.GetDeltaProfile( nProfileFrameLayerId, sPrevProfileType)
|
||||
local sNextProfileType = EgtGetInfo( nNextOutlineId, WIN_PROFILETYPE)
|
||||
local dNextCPDelta, _ = WinLib.GetDeltaProfile( nProfileFrameLayerId, sNextProfileType)
|
||||
-- calcolo spostamento della curva iniziale dovuto a posizione riferimento
|
||||
local nProfileFrameId = EgtGetFirstNameInGroup( nCurrProfileId, WIN_SECTIONFRAME)
|
||||
local frProfile = EgtFR( nProfileFrameId)
|
||||
local b3CurrProfileFrame = EgtGetBBoxRef( nCurrProfileRefId, GDB_BB.STANDARD, frProfile)
|
||||
local dCurrOffset = b3CurrProfileFrame:getMax():getX()
|
||||
-- creo copie degli outline e li offsetto opportunamente
|
||||
nCurrCurveId = EgtCopy( nOutlineId, nGeoLayerId)
|
||||
EgtOffsetCurve( nCurrCurveId, dCurrOffset)
|
||||
nCurrOffsetId = EgtCopy( nOutlineId, nGeoLayerId)
|
||||
EgtOffsetCurve( nCurrOffsetId, dCurrOffset - b3CurrProfileFrame:getDimX())
|
||||
EgtInvertCurve( nCurrOffsetId)
|
||||
if StartJointType == WIN_JNT.ANGLED then
|
||||
-- calcolo la bisettrice
|
||||
local vtMedia = ( ( EgtSV( nOutlineId) - EgtEV( nPrevOutlineId)) / 2)
|
||||
if not vtMedia:normalize() then
|
||||
vtMedia = EgtSV( nOutlineId)
|
||||
vtMedia:rotate(Z_AX(), 90)
|
||||
end
|
||||
nPrevCurveId = EgtLinePVL( nGeoLayerId, EgtSP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
|
||||
EgtInvertCurve( nPrevCurveId)
|
||||
else
|
||||
nPrevCurveId = EgtCopy( nPrevOutlineId, nGeoLayerId)
|
||||
end
|
||||
if ( StartJointType == WIN_JNT.FULL_V and ( nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.HORIZONTAL)) or
|
||||
( StartJointType == WIN_JNT.FULL_H and ( nProfileType == WIN_PRF.RIGHT or nProfileType == WIN_PRF.LEFT or nProfileType == WIN_PRF.VERTICAL)) or
|
||||
nProfileType == WIN_PRF.SPLIT then
|
||||
EgtOffsetCurve( nPrevCurveId, - dPrevCPDelta)
|
||||
EgtSetInfo( nGeoLayerId, WIN_STARTCPDELTA, dPrevCPDelta)
|
||||
end
|
||||
if EndJointType == WIN_JNT.ANGLED then
|
||||
-- calcolo la bisettrice
|
||||
local vtMedia = ( ( EgtSV( nNextOutlineId) - EgtEV( nOutlineId)) / 2)
|
||||
if not vtMedia:normalize() then
|
||||
vtMedia = EgtEV( nOutlineId)
|
||||
vtMedia:rotate(Z_AX(), 90)
|
||||
end
|
||||
nNextCurveId = EgtLinePVL( nGeoLayerId, EgtEP( nOutlineId), vtMedia, 3 * b3CurrProfileFrame:getDimX())
|
||||
EgtInvertCurve( nNextCurveId)
|
||||
else
|
||||
nNextCurveId = EgtCopy( nNextOutlineId, nGeoLayerId)
|
||||
end
|
||||
if ( StartJointType == WIN_JNT.FULL_V and ( nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.HORIZONTAL)) or
|
||||
( StartJointType == WIN_JNT.FULL_H and ( nProfileType == WIN_PRF.RIGHT or nProfileType == WIN_PRF.LEFT or nProfileType == WIN_PRF.VERTICAL)) or
|
||||
nProfileType == WIN_PRF.SPLIT then
|
||||
EgtOffsetCurve( nNextCurveId, - dNextCPDelta)
|
||||
EgtSetInfo( nGeoLayerId, WIN_ENDCPDELTA, dNextCPDelta)
|
||||
end
|
||||
dGeoWidth = b3CurrProfileFrame:getDimX()
|
||||
-- salvo delta controprofilo
|
||||
if StartJointType == WIN_JNT.FULL_V then
|
||||
end
|
||||
if EndJointType == WIN_JNT.FULL_V then
|
||||
end
|
||||
return nCurrCurveId, nCurrOffsetId, nPrevCurveId, nNextCurveId, dGeoWidth
|
||||
end
|
||||
|
||||
-- funzione che calcola l'ingombro dei pezzi del telaio
|
||||
function WinLib.CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId)
|
||||
-- recupero profilo
|
||||
local nProfileLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE)
|
||||
local nProfileFrameLayerId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_FRAME)
|
||||
-- creo layer per ingombro
|
||||
local nGeoLayerId = EgtGroup( nPartId)
|
||||
EgtSetName( nGeoLayerId, WIN_GEO)
|
||||
-- ricavo tipo dal nome
|
||||
local sName = EgtGetName( nOutlineId)
|
||||
local nProfileType = WIN_PRF.NULL
|
||||
if sName == WIN_TOP then
|
||||
nProfileType = WIN_PRF.TOP
|
||||
elseif sName == WIN_BOTTOM then
|
||||
nProfileType = WIN_PRF.BOTTOM
|
||||
elseif sName == WIN_LEFT then
|
||||
nProfileType = WIN_PRF.LEFT
|
||||
elseif sName == WIN_RIGHT then
|
||||
nProfileType = WIN_PRF.RIGHT
|
||||
elseif sName == WIN_VERTICAL then
|
||||
nProfileType = WIN_PRF.VERTICAL
|
||||
elseif sName == WIN_HORIZONTAL then
|
||||
nProfileType = WIN_PRF.HORIZONTAL
|
||||
elseif sName == WIN_SPLIT then
|
||||
nProfileType = WIN_PRF.SPLIT
|
||||
end
|
||||
local StartJointType
|
||||
local EndJointType
|
||||
local nNextOutlineId
|
||||
local nPrevOutlineId
|
||||
local nCurrCurveId
|
||||
local nCurrOffsetId
|
||||
local nPrevCurveId
|
||||
local nNextCurveId
|
||||
local dGeoWidth
|
||||
if nProfileType == WIN_PRF.TOP then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i')
|
||||
-- recupero outline precedente e successivo
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
elseif nProfileType == WIN_PRF.BOTTOM then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i')
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
elseif nProfileType == WIN_PRF.LEFT then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i')
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
elseif nProfileType == WIN_PRF.RIGHT then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i')
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
elseif nProfileType == WIN_PRF.VERTICAL then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = WIN_JNT.FULL_H
|
||||
EndJointType = WIN_JNT.FULL_H
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
elseif nProfileType == WIN_PRF.HORIZONTAL then
|
||||
-- recupero tipo di giunzioni
|
||||
StartJointType = WIN_JNT.FULL_V
|
||||
EndJointType = WIN_JNT.FULL_V
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
elseif nProfileType == WIN_PRF.SPLIT then
|
||||
local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
|
||||
local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
|
||||
local sStartName = EgtGetName( nStartId)
|
||||
local sEndName = EgtGetName( nEndId)
|
||||
-- recupero tipo di giunzioni
|
||||
if sStartName == WIN_BOTTOM or sStartName == WIN_TOP then
|
||||
StartJointType = WIN_JNT.FULL_H
|
||||
else
|
||||
StartJointType = WIN_JNT.FULL_V
|
||||
end
|
||||
if sEndName == WIN_BOTTOM or sEndName == WIN_TOP then
|
||||
EndJointType = WIN_JNT.FULL_H
|
||||
else
|
||||
EndJointType = WIN_JNT.FULL_V
|
||||
end
|
||||
-- recupero outline precedente
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sStartName)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sEndName)
|
||||
end
|
||||
-- creo lati dell'outline
|
||||
nCurrCurveId, nCurrOffsetId, nPrevCurveId, nNextCurveId, dGeoWidth = WinLib.CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, StartJointType, EndJointType, nProfileType, nGeoLayerId, nProfileFrameLayerId)
|
||||
-- calcolo punti di intersezione
|
||||
local ptIntersCurrPrev = EgtIP( nCurrCurveId, nPrevCurveId, EgtSP( nCurrCurveId))
|
||||
if not ptIntersCurrPrev then
|
||||
-- allungo per intersecare
|
||||
EgtExtendCurveStartByLen( nCurrCurveId, 200)
|
||||
EgtExtendCurveEndByLen( nPrevCurveId, 200)
|
||||
ptIntersCurrPrev = EgtIP( nCurrCurveId, nPrevCurveId, EgtSP( nCurrCurveId))
|
||||
end
|
||||
local ptIntersCurrNext = EgtIP( nCurrCurveId, nNextCurveId, EgtEP( nCurrCurveId))
|
||||
if not ptIntersCurrNext then
|
||||
-- allungo per intersecare
|
||||
EgtExtendCurveEndByLen( nCurrCurveId, 200)
|
||||
EgtExtendCurveStartByLen( nNextCurveId, 200)
|
||||
ptIntersCurrNext = EgtIP( nCurrCurveId, nNextCurveId, EgtEP( nCurrCurveId))
|
||||
end
|
||||
local ptIntersCurrOffsetPrev = EgtIP( nCurrOffsetId, nPrevCurveId, EgtEP( nCurrOffsetId))
|
||||
if not ptIntersCurrOffsetPrev then
|
||||
-- allungo per intersecare
|
||||
EgtExtendCurveEndByLen( nCurrOffsetId, 1000)
|
||||
EgtExtendCurveStartByLen( nPrevCurveId, 200)
|
||||
ptIntersCurrOffsetPrev = EgtIP( nCurrOffsetId, nPrevCurveId, EgtEP( nCurrOffsetId))
|
||||
end
|
||||
local ptIntersCurrOffsetNext = EgtIP( nCurrOffsetId, nNextCurveId, EgtSP( nCurrOffsetId))
|
||||
if not ptIntersCurrOffsetNext then
|
||||
-- allungo per intersecare
|
||||
EgtExtendCurveStartByLen( nCurrOffsetId, 1000)
|
||||
EgtExtendCurveStartByLen( nNextCurveId, 200)
|
||||
ptIntersCurrOffsetNext = EgtIP( nCurrOffsetId, nNextCurveId, EgtSP( nCurrOffsetId))
|
||||
end
|
||||
-- calcolo accorciamenti dei lati copiati alle intersezioni
|
||||
local dIntersCurrPrevParam = EgtCurveParamAtPoint( nCurrCurveId, ptIntersCurrPrev)
|
||||
EgtTrimCurveStartAtParam( nCurrCurveId, dIntersCurrPrevParam)
|
||||
local dIntersCurrNextParam = EgtCurveParamAtPoint( nCurrCurveId, ptIntersCurrNext)
|
||||
EgtTrimCurveEndAtParam( nCurrCurveId, dIntersCurrNextParam)
|
||||
local dIntersCurrOffsetNextParam = EgtCurveParamAtPoint( nCurrOffsetId, ptIntersCurrOffsetNext)
|
||||
EgtTrimCurveStartAtParam( nCurrOffsetId, dIntersCurrOffsetNextParam)
|
||||
local dIntersCurrOffsetPrevParam = EgtCurveParamAtPoint( nCurrOffsetId, ptIntersCurrOffsetPrev)
|
||||
EgtTrimCurveEndAtParam( nCurrOffsetId, dIntersCurrOffsetPrevParam)
|
||||
local dIntersPrevOffsetParam = EgtCurveParamAtPoint( nPrevCurveId, ptIntersCurrOffsetPrev)
|
||||
EgtTrimCurveStartAtParam( nPrevCurveId, dIntersPrevOffsetParam)
|
||||
local dIntersPrevCurrParam = EgtCurveParamAtPoint( nPrevCurveId, ptIntersCurrPrev)
|
||||
EgtTrimCurveEndAtParam( nPrevCurveId, dIntersPrevCurrParam)
|
||||
local dIntersNextCurrParam = EgtCurveParamAtPoint( nNextCurveId, ptIntersCurrNext)
|
||||
EgtTrimCurveStartAtParam( nNextCurveId, dIntersNextCurrParam)
|
||||
local dIntersNextOffsetParam = EgtCurveParamAtPoint( nNextCurveId, ptIntersCurrOffsetNext)
|
||||
EgtTrimCurveEndAtParam( nNextCurveId, dIntersNextOffsetParam)
|
||||
-- creo composita dai lati
|
||||
EgtSetName( nCurrCurveId, WIN_GEO_OUT)
|
||||
EgtSetName( nCurrOffsetId, WIN_GEO_IN)
|
||||
EgtSetName( nNextCurveId, WIN_GEO_RIGHT)
|
||||
EgtSetName( nPrevCurveId, WIN_GEO_LEFT)
|
||||
-- salvo spessore serramento in geo
|
||||
EgtSetInfo( nCurrCurveId, WIN_GEOWIDTH, dGeoWidth)
|
||||
|
||||
return nCurrCurveId
|
||||
end
|
||||
|
||||
-- funzione che posiziona i profili, li estrude e crea il solido
|
||||
function WinLib.CalcStartEndProfileType(nProfileType, nOutlineId)
|
||||
local StartJointType
|
||||
local EndJointType
|
||||
local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE)
|
||||
local sStartProfileType
|
||||
local sEndProfileType
|
||||
if nProfileType == WIN_PRF.BOTTOM then
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i')
|
||||
if StartJointType == WIN_JNT.FULL_H then
|
||||
sStartProfileType = WIN_OUTOFST
|
||||
elseif StartJointType == WIN_JNT.FULL_V then
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
elseif StartJointType == WIN_JNT.ANGLED then
|
||||
sStartProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
if EndJointType == WIN_JNT.FULL_H then
|
||||
sEndProfileType = WIN_OUTOFST
|
||||
elseif EndJointType == WIN_JNT.FULL_V then
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif EndJointType == WIN_JNT.ANGLED then
|
||||
sEndProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
elseif nProfileType == WIN_PRF.RIGHT then
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i')
|
||||
if StartJointType == WIN_JNT.FULL_H then
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
elseif StartJointType == WIN_JNT.FULL_V then
|
||||
sStartProfileType = WIN_OUTOFST
|
||||
elseif StartJointType == WIN_JNT.ANGLED then
|
||||
sStartProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
if EndJointType == WIN_JNT.FULL_H then
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif EndJointType == WIN_JNT.FULL_V then
|
||||
sEndProfileType = WIN_OUTOFST
|
||||
elseif EndJointType == WIN_JNT.ANGLED then
|
||||
sEndProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
elseif nProfileType == WIN_PRF.TOP then
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i')
|
||||
if StartJointType == WIN_JNT.FULL_H then
|
||||
sStartProfileType = WIN_OUTOFST
|
||||
elseif StartJointType == WIN_JNT.FULL_V then
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
elseif StartJointType == WIN_JNT.ANGLED then
|
||||
sStartProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
if EndJointType == WIN_JNT.FULL_H then
|
||||
sEndProfileType = WIN_OUTOFST
|
||||
elseif EndJointType == WIN_JNT.FULL_V then
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif EndJointType == WIN_JNT.ANGLED then
|
||||
sEndProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
elseif nProfileType == WIN_PRF.LEFT then
|
||||
StartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i')
|
||||
EndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i')
|
||||
if StartJointType == WIN_JNT.FULL_H then
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
elseif StartJointType == WIN_JNT.FULL_V then
|
||||
sStartProfileType = WIN_OUTOFST
|
||||
elseif StartJointType == WIN_JNT.ANGLED then
|
||||
sStartProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
if EndJointType == WIN_JNT.FULL_H then
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif EndJointType == WIN_JNT.FULL_V then
|
||||
sEndProfileType = WIN_OUTOFST
|
||||
elseif EndJointType == WIN_JNT.ANGLED then
|
||||
sEndProfileType = WIN_MINIZINKEN
|
||||
end
|
||||
elseif nProfileType == WIN_PRF.VERTICAL then
|
||||
StartJointType = WIN_JNT.FULL_H
|
||||
EndJointType = WIN_JNT.FULL_H
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif nProfileType == WIN_PRF.HORIZONTAL then
|
||||
StartJointType = WIN_JNT.FULL_V
|
||||
EndJointType = WIN_JNT.FULL_V
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
elseif nProfileType == WIN_PRF.SPLIT then
|
||||
local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
|
||||
local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
|
||||
local sStartName = EgtGetName( nStartId)
|
||||
local sEndName = EgtGetName( nEndId)
|
||||
-- recupero tipo di giunzioni
|
||||
if sStartName == WIN_BOTTOM or sStartName == WIN_TOP then
|
||||
StartJointType = WIN_JNT.FULL_H
|
||||
else
|
||||
StartJointType = WIN_JNT.FULL_V
|
||||
end
|
||||
if sEndName == WIN_BOTTOM or sEndName == WIN_TOP then
|
||||
EndJointType = WIN_JNT.FULL_H
|
||||
else
|
||||
EndJointType = WIN_JNT.FULL_V
|
||||
end
|
||||
sStartProfileType = WIN_CTRINOFST
|
||||
sEndProfileType = WIN_CTRINOFST
|
||||
end
|
||||
return sStartProfileType, sEndProfileType, StartJointType, EndJointType
|
||||
end
|
||||
|
||||
-- funzione che posiziona i profili, li estrude e crea il solido
|
||||
function WinLib.MakeSolidByExtrusion(nGeoId, nOutlineId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId)
|
||||
-- recupero outline
|
||||
local nPartId = EgtGetParent( nSolidLayerId)
|
||||
local nAreaId = EgtGetInfo( nPartId, WIN_AREA)
|
||||
local nGeoLayerId = EgtGetParent( nGeoId)
|
||||
-- recupero geo
|
||||
local nPrevGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_LEFT)
|
||||
local nNextGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_RIGHT)
|
||||
-- recupero BBox e larghezza del geo
|
||||
local dGeoWidth = EgtGetInfo( nGeoId, WIN_GEOWIDTH, 'd')
|
||||
-- creo guida Main
|
||||
local nGuideId = EgtCopy( nOutlineId, nSolidLayerId)
|
||||
EgtExtendCurveStartByLen( nGuideId, 2 * dGeoWidth)
|
||||
EgtExtendCurveEndByLen( nGuideId, 2 * dGeoWidth)
|
||||
-- recupero frame del profilo
|
||||
local nMainProfileFrameId = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTIONFRAME)
|
||||
local frInvertMainProfile = EgtFR( nMainProfileFrameId)
|
||||
frInvertMainProfile:invert()
|
||||
-- lo applico a tutte le geometrie del profilo
|
||||
EgtTransform( EgtGetAllInGroup( nMainProfileId), frInvertMainProfile)
|
||||
-- assegno come riferimento del profilo il punto start dell'outline
|
||||
EgtChangeGroupFrame( nMainProfileId, Frame3d( EgtSP( nGuideId), - EgtSV( nGuideId)))
|
||||
-- recupero outline del profilo Main e lo estrudo
|
||||
local nMainOutlineId = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTION)
|
||||
local nMainExtrusionId = EgtSurfTmSwept( nSolidLayerId, nMainOutlineId, nGuideId, false)
|
||||
-- posiziono il profilo Start
|
||||
local nRefStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, WIN_REF)
|
||||
local b3RefStartProfile = EgtGetBBoxGlob(nRefStartProfileId, GDB_BB.STANDARD)
|
||||
local dStartDelta = EgtGetInfo( nGeoLayerId, WIN_STARTCPDELTA, 'd') or 0
|
||||
-- creo guida per estrusione
|
||||
local nStartGuideId = EgtCopy( nPrevGeoId, nSolidLayerId)
|
||||
EgtExtendCurveStartByLen( nStartGuideId, 2 * dGeoWidth)
|
||||
EgtExtendCurveEndByLen( nStartGuideId, 2 * dGeoWidth)
|
||||
-- recupero frame del profilo
|
||||
local nStartProfileFrameId = EgtGetFirstNameInGroup( nStartProfileId, WIN_SECTIONFRAME)
|
||||
local frStartProfile = EgtFR( nStartProfileFrameId)
|
||||
-- lo sposto se controprofilo
|
||||
frStartProfile:move( - frStartProfile:getVersX() * dStartDelta)
|
||||
frStartProfile:invert()
|
||||
-- lo applico a tutte le geometrie del profilo
|
||||
EgtTransform( EgtGetAllInGroup( nStartProfileId), frStartProfile)
|
||||
-- assegno come riferimento del profilo il punto start dell'outline
|
||||
EgtChangeGroupFrame( nStartProfileId, Frame3d( EgtSP( nStartGuideId), - EgtSV( nStartGuideId)))
|
||||
-- in base al tipo di incastro e di pezzo, ricavo i controprofili
|
||||
local sStartProfileType
|
||||
local sEndProfileType
|
||||
-- recupero tipo di giunzioni
|
||||
sStartProfileType, sEndProfileType, StartJointType, EndJointType = WinLib.CalcStartEndProfileType( nProfileType, nOutlineId)
|
||||
-- recupero outline del profilo Start e lo estrudo
|
||||
local nOutStartProfileId
|
||||
if sStartProfileType == WIN_MINIZINKEN then
|
||||
nOutStartProfileId = EgtLine( nStartProfileId, EgtSP( nPrevGeoId), EgtSP( nPrevGeoId) - Z_AX() * b3RefStartProfile:getDimY(), GDB_RT.GLOB)
|
||||
EgtInvertCurve( nOutStartProfileId)
|
||||
else
|
||||
nOutStartProfileId = EgtGetFirstNameInGroup( nStartProfileId, sStartProfileType)
|
||||
end
|
||||
local nStartExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutStartProfileId, nStartGuideId, false)
|
||||
-- taglio estrusi per ottenere solido
|
||||
local nExtrCopyId = EgtCopy( nMainExtrusionId, nSolidLayerId)
|
||||
EgtSurfTmCut( nMainExtrusionId, nStartExtrusionId, true, false)
|
||||
EgtSurfTmCut( nStartExtrusionId, nExtrCopyId, true, false)
|
||||
-- posiziono il profilo End
|
||||
local nRefEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, WIN_REF)
|
||||
local b3RefEndProfile = EgtGetBBoxGlob(nRefEndProfileId, GDB_BB.STANDARD)
|
||||
local dEndDelta = EgtGetInfo( nGeoLayerId, WIN_ENDCPDELTA, 'd') or 0
|
||||
-- creo guida per estrusione
|
||||
local nEndGuideId = EgtCopy( nNextGeoId, nSolidLayerId)
|
||||
EgtExtendCurveStartByLen( nEndGuideId, 2 * dGeoWidth)
|
||||
EgtExtendCurveEndByLen( nEndGuideId, 2 * dGeoWidth)
|
||||
-- recupero frame del profilo
|
||||
local nEndProfileFrameId = EgtGetFirstNameInGroup( nEndProfileId, WIN_SECTIONFRAME)
|
||||
local frEndProfile = EgtFR( nEndProfileFrameId)
|
||||
frEndProfile:move( - frEndProfile:getVersX() * dEndDelta)
|
||||
frEndProfile:invert()
|
||||
-- lo applico a tutte le geometrie del profilo
|
||||
EgtTransform( EgtGetAllInGroup( nEndProfileId), frEndProfile)
|
||||
-- assegno come riferimento del profilo il punto start dell'outline
|
||||
EgtChangeGroupFrame( nEndProfileId, Frame3d( EgtSP( nEndGuideId), - EgtSV( nEndGuideId)))
|
||||
-- recupero outline del profilo End e lo estrudo
|
||||
local nOutEndProfileId
|
||||
if sEndProfileType == WIN_MINIZINKEN then
|
||||
nOutEndProfileId = EgtLine( nEndProfileId, EgtSP( nNextGeoId), EgtSP( nNextGeoId) - Z_AX() * b3RefEndProfile:getDimY(), GDB_RT.GLOB)
|
||||
else
|
||||
nOutEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, sEndProfileType)
|
||||
end
|
||||
-- if (EndJointType == WIN_JNT.FULL_H and ( nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.LEFT)) or
|
||||
-- (EndJointType == WIN_JNT.FULL_V and ( nProfileType == WIN_PRF.RIGHT)) then
|
||||
-- EgtInvertCurve( nOutEndProfileId)
|
||||
-- end
|
||||
local nEndExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutEndProfileId, nEndGuideId, false)
|
||||
-- taglio estrusi per ottenere solido
|
||||
EgtSurfTmCut( nMainExtrusionId, nEndExtrusionId, true, false)
|
||||
EgtSurfTmCut( nEndExtrusionId, nExtrCopyId, true, false)
|
||||
EgtErase( nExtrCopyId)
|
||||
end
|
||||
|
||||
-- funzione che crea il solido del pezzo del telaio
|
||||
function WinLib.CalcFrameSolid(nPartId, nOutlineId, nGeoId, nOutlineLayerId)
|
||||
-- recupero profilo
|
||||
local nProfileId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_PROFILE)
|
||||
local nProfileFrameLayerId = EgtGetFirstNameInGroup( nProfileId, WIN_FRAME)
|
||||
-- creo layer per solido e per profili di estrusione
|
||||
local nSolidLayerId = EgtGroup( nPartId)
|
||||
EgtSetName( nSolidLayerId, WIN_SOLID)
|
||||
local nFrameProfileLayerId = EgtGroup( nPartId)
|
||||
EgtSetName( nFrameProfileLayerId, WIN_PROFILE)
|
||||
-- ricavo tipo dal nome
|
||||
local sName = EgtGetName( nPartId)
|
||||
local nProfileType = WIN_PRF.NULL
|
||||
if sName == WIN_TOP then
|
||||
nProfileType = WIN_PRF.TOP
|
||||
elseif sName == WIN_BOTTOM then
|
||||
nProfileType = WIN_PRF.BOTTOM
|
||||
elseif sName == WIN_LEFT then
|
||||
nProfileType = WIN_PRF.LEFT
|
||||
elseif sName == WIN_RIGHT then
|
||||
nProfileType = WIN_PRF.RIGHT
|
||||
elseif sName == WIN_VERTICAL then
|
||||
nProfileType = WIN_PRF.VERTICAL
|
||||
elseif sName == WIN_HORIZONTAL then
|
||||
nProfileType = WIN_PRF.HORIZONTAL
|
||||
elseif sName == WIN_SPLIT then
|
||||
nProfileType = WIN_PRF.SPLIT
|
||||
end
|
||||
local nPrevOutlineId
|
||||
local nNextOutlineId
|
||||
local nOrigMainProfileId = GDB_ID.NULL
|
||||
local nMainProfileId = GDB_ID.NULL
|
||||
local nOrigStartProfileId = GDB_ID.NULL
|
||||
local nStartProfileId = GDB_ID.NULL
|
||||
local nOrigEndProfileId = GDB_ID.NULL
|
||||
local nEndProfileId = GDB_ID.NULL
|
||||
-- recupero outline precedente e successivo
|
||||
if nProfileType == WIN_PRF.BOTTOM then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
elseif nProfileType == WIN_PRF.RIGHT then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
elseif nProfileType == WIN_PRF.TOP then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
elseif nProfileType == WIN_PRF.LEFT then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
elseif nProfileType == WIN_PRF.VERTICAL then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_BOTTOM)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_TOP)
|
||||
elseif nProfileType == WIN_PRF.HORIZONTAL then
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_LEFT)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
elseif nProfileType == WIN_PRF.SPLIT then
|
||||
local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i')
|
||||
local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i')
|
||||
local sStartName = EgtGetName( nStartId)
|
||||
local sEndName = EgtGetName( nEndId)
|
||||
nPrevOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sStartName)
|
||||
nNextOutlineId = EgtGetFirstNameInGroup( nOutlineLayerId, sEndName)
|
||||
end
|
||||
-- recupero profilo e controprofili
|
||||
local sCurrProfileType = EgtGetInfo( nOutlineId, WIN_PROFILETYPE)
|
||||
local sPrevProfileType = EgtGetInfo( nPrevOutlineId, WIN_PROFILETYPE)
|
||||
local sNextProfileType = EgtGetInfo( nNextOutlineId, WIN_PROFILETYPE)
|
||||
nOrigMainProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, sCurrProfileType)
|
||||
nOrigStartProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, sPrevProfileType)
|
||||
nOrigEndProfileId = EgtGetFirstNameInGroup( nProfileFrameLayerId, sNextProfileType)
|
||||
-- creo copie di profilo e controprofili
|
||||
nMainProfileId = EgtCopy( nOrigMainProfileId, nFrameProfileLayerId)
|
||||
EgtSetName( nMainProfileId, WIN_PRF_MAIN)
|
||||
nStartProfileId = EgtCopy( nOrigStartProfileId, nFrameProfileLayerId)
|
||||
EgtSetName( nStartProfileId, WIN_PRF_START)
|
||||
nEndProfileId = EgtCopy( nOrigEndProfileId, nFrameProfileLayerId)
|
||||
EgtSetName( nEndProfileId, WIN_PRF_END)
|
||||
-- creo solido dai profili
|
||||
WinLib.MakeSolidByExtrusion(nGeoId, nOutlineId, nMainProfileId, nStartProfileId, nEndProfileId, nProfileType, nSolidLayerId)
|
||||
end
|
||||
|
||||
-- funzione che calcola l'ingombro dei pezzi del telaio
|
||||
function WinLib.CreatePartFromOutline( nAreaLayerId, nOutlineId)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nAreaLayerId, WIN_OUTLINE)
|
||||
-- se area senza outline, cerco quella superiore
|
||||
if not nOutlineLayerId then
|
||||
local nParentAreaLayerId = EgtGetParent( nAreaLayerId)
|
||||
if nParentAreaLayerId then
|
||||
nOutlineLayerId = EgtGetFirstNameInGroup( nParentAreaLayerId, WIN_OUTLINE)
|
||||
end
|
||||
end
|
||||
-- ricavo tipo dal nome
|
||||
local sName = EgtGetName( nOutlineId)
|
||||
local nProfileType = WIN_PRF.NULL
|
||||
if sName == WIN_TOP then
|
||||
nProfileType = WIN_PRF.TOP
|
||||
elseif sName == WIN_BOTTOM then
|
||||
nProfileType = WIN_PRF.BOTTOM
|
||||
elseif sName == WIN_LEFT then
|
||||
nProfileType = WIN_PRF.LEFT
|
||||
elseif sName == WIN_RIGHT then
|
||||
nProfileType = WIN_PRF.RIGHT
|
||||
elseif sName == WIN_VERTICAL then
|
||||
nProfileType = WIN_PRF.VERTICAL
|
||||
elseif sName == WIN_HORIZONTAL then
|
||||
nProfileType = WIN_PRF.HORIZONTAL
|
||||
elseif sName == WIN_SPLIT then
|
||||
nProfileType = WIN_PRF.SPLIT
|
||||
end
|
||||
-- creo pezzo
|
||||
local nPartId = EgtGroup( GDB_ID.ROOT)
|
||||
EgtSetName( nPartId, sName)
|
||||
if nProfileType == WIN_PRF.BOTTOM or nProfileType == WIN_PRF.TOP or nProfileType == WIN_PRF.HORIZONTAL then
|
||||
EgtSetColor( nPartId, Color3d( 204, 102, 0))
|
||||
elseif nProfileType == WIN_PRF.RIGHT or nProfileType == WIN_PRF.LEFT or nProfileType == WIN_PRF.VERTICAL then
|
||||
EgtSetColor( nPartId, Color3d( 251, 128, 4))
|
||||
else
|
||||
EgtSetColor( nPartId, Color3d( 255, 159, 57))
|
||||
end
|
||||
|
||||
-- inserisco riferimento alla sua area
|
||||
EgtSetInfo( nPartId, WIN_AREA, nAreaLayerId)
|
||||
|
||||
-- disegno ingombro
|
||||
local nGeoId = WinLib.CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId)
|
||||
|
||||
-- disegno solido
|
||||
WinLib.CalcFrameSolid(nPartId, nOutlineId, nGeoId, nOutlineLayerId)
|
||||
|
||||
-- offset per distanziare i pezzi
|
||||
--local dYPosOffset = 300 * ( nProfileType - 1)
|
||||
--EgtChangeGroupFrame( nPartId, Frame3d( Point3d( 0, dYPosOffset, 0)))
|
||||
|
||||
end
|
||||
|
||||
-- funzione che posiziona un pezzo
|
||||
function WinLib.PositionPart(nPartId)
|
||||
-- ricavo tipo dal nome
|
||||
local sName = EgtGetName( nPartId)
|
||||
local sDelta = ''
|
||||
if sName == WIN_BOTTOM then
|
||||
sDelta = WIN_STARTCPDELTA
|
||||
elseif sName == WIN_RIGHT then
|
||||
sDelta = WIN_STARTCPDELTA
|
||||
elseif sName == WIN_TOP then
|
||||
sDelta = WIN_STARTCPDELTA
|
||||
elseif sName == WIN_LEFT then
|
||||
sDelta = WIN_STARTCPDELTA
|
||||
end
|
||||
-- calcolo nuovo riferimento
|
||||
local nGeoPartLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO)
|
||||
local nGeoPartId = EgtGetFirstNameInGroup( nGeoPartLayerId, sName)
|
||||
local dDelta = EgtGetInfo( nGeoPartId, sDelta, 'd') or 0
|
||||
local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME)
|
||||
local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE)
|
||||
local nFramePartId = EgtGetFirstNameInGroup( nOutlineLayerId, sName)
|
||||
local vtStart = EgtSV( nFramePartId)
|
||||
local ptStart = EgtSP( nFramePartId) + vtStart * dDelta
|
||||
local _, _, dAngRight = SphericalFromVector(vtStart)
|
||||
local frStart = Frame3d( ptStart)
|
||||
frStart:rotate( frStart:getOrigin(), Z_AX(), dAngRight)
|
||||
EgtChangeGroupFrame( nPartId, frStart)
|
||||
end
|
||||
|
||||
-- funzione che assembla i pezzi
|
||||
function WinLib.AssembleFrame()
|
||||
local nBottomPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_BOTTOM)
|
||||
WinLib.PositionPart(nBottomPartId)
|
||||
local nRightPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_RIGHT)
|
||||
WinLib.PositionPart(nRightPartId)
|
||||
local nTopPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_TOP)
|
||||
WinLib.PositionPart(nTopPartId)
|
||||
local nLeftPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_LEFT)
|
||||
WinLib.PositionPart(nLeftPartId)
|
||||
-- assemblo i pezzi
|
||||
--local nRightPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_RIGHT)
|
||||
--local nGeoRightLayerId = EgtGetFirstNameInGroup( nRightPartId, WIN_GEO)
|
||||
--local nGeoRightId = EgtGetFirstNameInGroup( nGeoRightLayerId, WIN_RIGHT)
|
||||
--local dDelta = EgtGetInfo( nGeoRightId, WIN_BOTTOMCPDELTA, 'd')
|
||||
--local nFrameLayerId = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_FRAME)
|
||||
--local nOutlineLayerId = EgtGetFirstNameInGroup( nFrameLayerId, WIN_OUTLINE)
|
||||
--local nFrameRightId = EgtGetFirstNameInGroup( nOutlineLayerId, WIN_RIGHT)
|
||||
--local vtRight = EgtSV( nFrameRightId)
|
||||
--local ptRight = EgtSP( nFrameRightId) + vtRight * dDelta
|
||||
--local _, _, dAngRight = SphericalFromVector(vtRight)
|
||||
--local frRight = Frame3d( ptRight)
|
||||
--frRight:rotate( frRight:getOrigin(), Z_AX(), dAngRight)
|
||||
--EgtChangeGroupFrame( nRightPartId, frRight)
|
||||
end
|
||||
|
||||
---------------------------------------------------------------------
|
||||
return WinLib
|
||||
Reference in New Issue
Block a user