diff --git a/Profiles/Main.lua b/Profiles/Main.lua index d13a35a..ea215d8 100644 --- a/Profiles/Main.lua +++ b/Profiles/Main.lua @@ -57,9 +57,17 @@ EgtNewFile() -- importo profilo prescelto WinCreate.ImportProfile( sProfilePath) --- creo telaio rettangolare +-- creo telaio generico local FrameJointType = WIN_JNT.FULL_H -local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointType, FrameJointType, FrameJointType, FrameJointType) + +local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.RECT, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER_SIDE, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 500) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER_SIDE, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight + 500, WindowHeight) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.CHAMFER, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 500) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.ROUND_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.SEGMENTAL_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 100) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.POINTED_ARC, FrameJointType, FrameJointType, FrameJointType, FrameJointType, WindowWidth, WindowHeight, WindowHeight + 600) +-- local nFrameId = WinCreate.CreateFrame( WIN_FRAME_TYPE.TRG, FrameJointType, FrameJointType, WIN_JNT.ANGLED, WIN_JNT.ANGLED, WindowWidth, WindowHeight, 0) -- -- creo telaio generico -- local nDrawFramePartId = EgtGroup( GDB_ID.ROOT) @@ -71,23 +79,23 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp -- --local nFrameTopId = EgtLine( nDrawFrameLayerId, Point3d( WindowWidth, WindowHeight, 0), Point3d( 0, WindowHeight, 0)) -- local nFrameLeftId = EgtLine( nDrawFrameLayerId, Point3d( 0, WindowHeight, 0), Point3d( 0, 0, 0)) -- local FrameJointType = WIN_JNT.ANGLED --- local nFrameId = WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, FrameJointType, FrameJointType, FrameJointType, FrameJointType) +-- local nFrameId = WinCreate.CreateGenFrame( {nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId}, FrameJointType, FrameJointType, FrameJointType, FrameJointType) ------------------------ Finestra vetro fisso ------------------------ --- -- aggiungo zoccolo --- WinCreate.AddBottomRail( nFrameId) --- -- aggiungo vetro --- local nFillId = WinCreate.AddFill( nFrameId, WIN_FILLTYPES.GLASS) +-- aggiungo zoccolo +WinCreate.AddBottomRail( nFrameId) +-- aggiungo vetro +local nFillId = WinCreate.AddFill( nFrameId, WIN_FILLTYPES.GLASS) ------------------------ Finestra vetro fisso con divisione orizzontale ------------------------ -- -- aggiungo zoccolo -- WinCreate.AddBottomRail( nFrameId) - +-- -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS) @@ -96,10 +104,10 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp -- -- aggiungo zoccolo -- WinCreate.AddBottomRail( nFrameId) - +-- -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS) @@ -108,36 +116,36 @@ local nFrameId = WinCreate.CreateFrame( WindowWidth, WindowHeight, FrameJointTyp -- -- aggiungo zoccolo -- WinCreate.AddBottomRail( nFrameId) - +-- -- -- definisco divisioni -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2) -- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) -- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea11Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea12Id, WIN_FILLTYPES.GLASS) -- local nFill3Id = WinCreate.AddFill( nArea21Id, WIN_FILLTYPES.GLASS) -- local nFill4Id = WinCreate.AddFill( nArea22Id, WIN_FILLTYPES.GLASS) --- ------------------------ Finestra anta singola ------------------------ +------------------------ Finestra anta singola ------------------------ --- aggiungo anta -local SashJointType = WIN_JNT.FULL_V -local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType) - --- aggiungo vetro -local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) +-- -- aggiungo anta +-- local SashJointType = WIN_JNT.FULL_V +-- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType) +-- +-- -- aggiungo vetro +-- local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) ------------------------ Finestra anta singola con divisione orizzontale ------------------------ -- -- aggiungo anta -- local SashJointType = WIN_JNT.FULL_V -- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS) @@ -147,10 +155,10 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- aggiungo anta -- local SashJointType = WIN_JNT.FULL_V -- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea1Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea2Id, WIN_FILLTYPES.GLASS) @@ -160,12 +168,12 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- aggiungo anta -- local SashJointType = WIN_JNT.FULL_V -- local nSashId = WinCreate.AddSash( nFrameId, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- definisco divisioni -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nSashId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2) -- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) -- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) - +-- -- -- aggiungo vetri -- local nFill1Id = WinCreate.AddFill( nArea11Id, WIN_FILLTYPES.GLASS) -- local nFill2Id = WinCreate.AddFill( nArea12Id, WIN_FILLTYPES.GLASS) @@ -198,17 +206,17 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2) - +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) @@ -216,17 +224,17 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 2, _, WIN_SPLITTYPES.FRENCH) - +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE) - +-- -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE) - +-- -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) @@ -251,27 +259,27 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) ------------------------ Finestra tripla anta con montanti verticali ------------------------ -- -- definisco prima divisione --- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) - +-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) +-- -- -- definisco seconda divisione --- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) - +-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo terza anta -- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) @@ -307,27 +315,27 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) ------------------------ Finestra tripla anta con montante verticale e ante battente e ricevente ------------------------ -- -- definisco prima divisione --- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) - +-- local nArea1Id, nArea0Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) +-- -- -- definisco seconda divisione --- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) - +-- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea0Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3, _, WIN_SPLITTYPES.FRENCH) +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.INACTIVE) - +-- -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo terza anta -- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType, WIN_SASHTYPES.ACTIVE) - +-- -- -- aggiungo vetro -- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) @@ -335,26 +343,26 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- definisco prima divisione -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3) - +-- -- -- definisco seconda divisione -- local nArea2Id, nArea3Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 3) - +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea1Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea2Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo terza anta -- local nSash3Id = WinCreate.AddSash( nArea3Id, SashJointType, SashJointType, SashJointType, SashJointType) - +-- -- -- aggiungo vetro -- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) @@ -461,39 +469,39 @@ local nFillId = WinCreate.AddFill( nSashId, WIN_FILLTYPES.GLASS) -- -- definisco divisione orizzontale -- local nArea1Id, nArea2Id = WinCreate.AddSplit( nFrameId, WIN_SPLITORIENTATION.HORIZONTAL, WIN_MEASURE.ABSOLUT, WindowHeight / 2) - +-- -- -- definisco divisioni verticali -- local nArea11Id, nArea12Id = WinCreate.AddSplit( nArea1Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) -- local nArea12Id, nArea13Id = WinCreate.AddSplit( nArea12Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) -- local nArea21Id, nArea23Id = WinCreate.AddSplit( nArea2Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) --- local nArea21Id, nArea22Id = WinCreate.AddSplit( nArea21Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) - +-- local nArea22Id, nArea23Id = WinCreate.AddSplit( nArea23Id, WIN_SPLITORIENTATION.VERTICAL, WIN_MEASURE.ABSOLUT, WindowWidth / 3) +-- -- -- aggiungo prima anta -- local SashJointType = WIN_JNT.FULL_V -- local nSash1Id = WinCreate.AddSash( nArea11Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro -- local nFill1Id = WinCreate.AddFill( nSash1Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo seconda anta -- local nSash2Id = WinCreate.AddSash( nArea12Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro -- local nFill2Id = WinCreate.AddFill( nSash2Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo terza anta -- local nSash3Id = WinCreate.AddSash( nArea13Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro -- local nFill3Id = WinCreate.AddFill( nSash3Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo quarta anta -- local nSash4Id = WinCreate.AddSash( nArea21Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro -- local nFill4Id = WinCreate.AddFill( nSash4Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo quinta anta -- local nSash5Id = WinCreate.AddSash( nArea22Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro -- local nFill5Id = WinCreate.AddFill( nSash5Id, WIN_FILLTYPES.GLASS) - +-- -- -- aggiungo sesta anta -- local nSash6Id = WinCreate.AddSash( nArea23Id, SashJointType, SashJointType, SashJointType, SashJointType) -- -- aggiungo vetro diff --git a/Profiles/WinConst.lua b/Profiles/WinConst.lua index 0ff97e1..78a130c 100644 --- a/Profiles/WinConst.lua +++ b/Profiles/WinConst.lua @@ -18,6 +18,17 @@ local WinConst = {} ------------------------------------------- PARAMETERS ------------------------------------------- +-- tipi di telaio +WIN_FRAME_TYPE = { + RECT = 1, + CHAMFER_SIDE = 2, + CHAMFER = 3, + ROUND_ARC = 4, + SEGMENTAL_ARC = 5, + POINTED_ARC = 6, + TRIANGLE = 7, +} + -- Tipi di giunzioni (joint) WIN_JNT = { ANGLED = 1, diff --git a/Profiles/WinLib/WinCalculate.lua b/Profiles/WinLib/WinCalculate.lua index c7ab79b..c73607c 100644 --- a/Profiles/WinLib/WinCalculate.lua +++ b/Profiles/WinLib/WinCalculate.lua @@ -35,13 +35,59 @@ local function CopyInfo( nDest, nSou, sInfo) EgtSetInfo( nDest, sInfo, sVal) end +--------------------------------------------------------------------- +-- funzione che trova punto di intersezione fra due curve eventualmente estendendole +local function FindIntersectionPoint( nCrv1, nCrv2) + local ptRef = EgtSP( nCrv1) + local ptInt = EgtIP( nCrv1, nCrv2, ptRef) + if not ptInt then + -- se entrambe linee + if EgtGetType( nCrv1) == GDB_TY.CRV_LINE and EgtGetType( nCrv2) == GDB_TY.CRV_LINE then + EgtExtendCurveStartByLen( nCrv1, 10000) + EgtExtendCurveEndByLen( nCrv1, 10000) + EgtExtendCurveStartByLen( nCrv2, 10000) + EgtExtendCurveEndByLen( nCrv2, 10000) + ptInt = EgtIP( nCrv1, nCrv2, ptRef) + + -- se entrambi archi + elseif EgtGetType( nCrv1) == GDB_TY.CRV_ARC and EgtGetType( nCrv2) == GDB_TY.CRV_ARC then + -- TO DO. Al momento non ci sono esempi di questo tipo + + -- se arco e linea + else + local nLine = EgtIf( EgtGetType( nCrv1) == GDB_TY.CRV_LINE, nCrv1, nCrv2) + local nArc = EgtIf( nLine == nCrv1, nCrv2, nCrv1) + -- tento di trovare intersezione prolungando la linea + EgtExtendCurveStartByLen( nLine, 10000) + EgtExtendCurveEndByLen( nLine, 10000) + ptInt = EgtIP( nArc, nLine, ptRef) + if not ptInt then + -- creo circonferenza corrispondente all'arco + local nCircle = EgtCircle( GDB_ID.ROOT, EgtCP( nArc), EgtArcRadius( nArc)) + -- trovo l'intersezione tra retta e circonferenza + local ptDist = EgtIf( nArc == nCrv2, EgtEP( nArc), EgtSP( nArc)) + local _, ptRef = EgtPointCurveDist( ptDist, nLine) + ptInt = EgtIP( nCircle, nLine, ptRef) + EgtErase( nCircle) + -- allungo l'arco per arrivare al punto di intersezione + if nArc == nCrv2 then + EgtModifyCurveEndPoint( nArc, ptInt) + else + EgtModifyCurveStartPoint( nArc, ptInt) + end + end + end + end + + return ptInt +end + --------------------------------------------------------------------- -- funzione che dato un gruppo contenente curve ordinate che creano una curva chiusa, -- ne estende/taglia i contorni per ottenere una curva chiusa continua local function TrimAndOrientOrderedCurveLayer( nLayerId) local IntersCurveList = {} local LastCurveInters - local ptInters local nCurveId = EgtGetFirstInGroup( nLayerId) -- ciclo sui segmenti per ottenere lista intersezioni while nCurveId do @@ -49,15 +95,7 @@ local function TrimAndOrientOrderedCurveLayer( nLayerId) if not nPrevId then nPrevId = EgtGetLastInGroup( nLayerId) end - ptInters = EgtIP( nCurveId, nPrevId, EgtSP( nCurveId)) - if not ptInters then - local dDist = dist( EgtEP( nPrevId), EgtSP( nCurveId)) - EgtExtendCurveStartByLen( nCurveId, 2 * dDist) - EgtExtendCurveEndByLen( nCurveId, 2 * dDist) - EgtExtendCurveStartByLen( nPrevId, 2 * dDist) - EgtExtendCurveEndByLen( nPrevId, 2 * dDist) - ptInters = EgtIP( nCurveId, nPrevId, EgtSP( nCurveId)) - end + local ptInters = FindIntersectionPoint( nCurveId, nPrevId) if LastCurveInters then LastCurveInters.EndInters = Point3d( ptInters) end @@ -67,11 +105,12 @@ local function TrimAndOrientOrderedCurveLayer( nLayerId) nCurveId = EgtGetNext( nCurveId) end IntersCurveList[#IntersCurveList].EndInters = IntersCurveList[1].StartInters + -- ciclo per tagliare ed orientare for nIntersCurveIndex = 1, #IntersCurveList do local CurveInters = IntersCurveList[nIntersCurveIndex] - local dStartParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.StartInters) - local dEndParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.EndInters) + local dStartParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.StartInters, 100 * GEO.EPS_SMALL) + local dEndParam = EgtCurveParamAtPoint( CurveInters.CurveId, CurveInters.EndInters, 100 * GEO.EPS_SMALL) EgtTrimCurveStartEndAtParam( CurveInters.CurveId, min( dStartParam, dEndParam), max( dStartParam, dEndParam)) if dStartParam > dEndParam then EgtInvertCurve( CurveInters.CurveId) @@ -91,7 +130,7 @@ local function TrimSplitWithOutline( nSplitId) nOutlineId = EgtGetInfo( nEndIntersId, WIN_COPY, 'i') local ptEndInters = EgtIP( nSplitId, nOutlineId, EgtSP( nSplitId)) local dEndInters = EgtCurveParamAtPoint( nSplitId, ptEndInters) - EgtTrimCurveEndAtParam( nSplitId, dEndInters) + EgtTrimCurveEndAtParam( nSplitId, dEndInters) end --------------------------------------------------------------------- @@ -727,69 +766,54 @@ local function GetOutlineProfileType( nOutlineId, bBottomRail) end --------------------------------------------------------------------- --- funzione che recupera l'outline precedente e successivo +-- funzione che recupera gli outline precedenti e successivi local function GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) - local nPrevOutlineId - local nNextOutlineId + local vPrevOutlineId = {} + local vNextOutlineId = {} if nProfileType == WIN_PRF.SPLIT then - -- se split individuo l'outline associato al base outline che lo taglia - local nPrevBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i') - nPrevOutlineId = EgtGetInfo( nPrevBaseOutlineId, WIN_COPY, 'i') - local nNextBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i') - nNextOutlineId = EgtGetInfo( nNextBaseOutlineId, WIN_COPY, 'i') + -- se split recupero tutte le curve di base outline che lo tagliano + local vPrevBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'vi') + for i = 1, #vPrevBaseOutlineId do + -- recupero l'outline associato al base outline che lo taglia + table.insert( vPrevOutlineId, EgtGetInfo( vPrevBaseOutlineId[i], WIN_COPY, 'i')) + end + local vNextBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'vi') + for i = 1, #vNextBaseOutlineId do + table.insert( vNextOutlineId, EgtGetInfo( vNextBaseOutlineId[i], WIN_COPY, 'i')) + end else - nPrevOutlineId = EgtGetPrev( nOutlineId) - if not nPrevOutlineId then - nPrevOutlineId = EgtGetLastInGroup( nOutlineLayerId) - end - nNextOutlineId = EgtGetNext( nOutlineId) - if not nNextOutlineId then - nNextOutlineId = EgtGetFirstInGroup( nOutlineLayerId) - end + vPrevOutlineId = { EgtGetPrev( nOutlineId) or EgtGetLastInGroup( nOutlineLayerId)} + vNextOutlineId = { EgtGetNext( nOutlineId) or EgtGetFirstInGroup( nOutlineLayerId)} end - return nPrevOutlineId, nNextOutlineId + return vPrevOutlineId, vNextOutlineId end --------------------------------------------------------------------- -- funzione che restituisce il tipo di controprofilo dell'outline adiacente -local function GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId) +local function GetProfileCtrIn( nPrevOutlineId, nOutlineId, nPrevProfileId) local sPrevCtrIn = WIN_CTRIN - -- gestione particolare nel caso di split su split - if nProfileType == WIN_PRF.SPLIT then - -- recupero il base outline del prev e verifico se deriva da uno split + -- gestione particolare del caso di profilo di split + if not EgtGetFirstNameInGroup( nPrevProfileId, sPrevCtrIn) then + -- recupero la curva di base outline da cui deriva il precedente local nPrevSouId = EgtGetInfo( nPrevOutlineId, WIN_COPY, 'i') local sPrevSouName repeat nPrevSouId = EgtGetInfo( nPrevSouId, WIN_SOU, 'i') sPrevSouName = EgtGetName( nPrevSouId or GDB_ID.NULL) until not nPrevSouId or sPrevSouName == WIN_SPLIT - if sPrevSouName == WIN_SPLIT then - -- verifico da che lato sono dello split - local dOutlineDist, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) - -- recupero box dei controprofili rispetto al loro sistema di riferimento - local nSectionFrameId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_SECTIONFRAME) - local frSectionFrame = EgtFR( nSectionFrameId, GDB_ID.ROOT) - local dMinDist = GEO.INFINITO - -- confronto distanze dei controprofili rispetto a distanza dell'outline per trovare il controprofilo piu' vicino - local nMinCtrInId - local nCtrInId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_CTRIN .. '*') - while nCtrInId do - local b3CtrIn = EgtGetBBoxRef( nCtrInId, GDB_BB.STANDARD, frSectionFrame) - local dCtrInDist = abs( ( dSide * dOutlineDist) - b3CtrIn:getCenter():getX()) - if dCtrInDist < dMinDist then - dMinDist = dCtrInDist - nMinCtrInId = nCtrInId - end - nCtrInId = EgtGetNextName( nCtrInId, WIN_CTRIN .. '*') - end - if nMinCtrInId then - sPrevCtrIn = EgtGetName( nMinCtrInId) - end + + -- verifico da quale lato si trova la curva per decidere quale controprofilo considerare + local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) + if dSide == 1 then + sPrevCtrIn = WIN_CTRIN .. '1' -- dx + else + sPrevCtrIn = WIN_CTRIN .. '2' -- sx end end + return sPrevCtrIn end @@ -822,32 +846,39 @@ end --------------------------------------------------------------------- -- funzione che crea il gruppo con i profili di un pezzo -local function CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType) +local function CalcFrameProfiles( nPartId, nOutlineId, vPrevOutlineId, vNextOutlineId, nProfileType) -- creo gruppo per i profili local nProfileLayerId = EgtGroup( nPartId) EgtSetName( nProfileLayerId, WIN_PROFILE) EgtSetStatus( nProfileLayerId, GDB_ST.OFF) - -- recupero profili e controprofili - local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, nProfileType == WIN_PRF.BOTTOMRAIL) - -- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom - local nOrigStartProfileId = GetOutlineProfileId( nPrevOutlineId, nProfileType == WIN_PRF.SPLIT) - local nOrigEndProfileId = GetOutlineProfileId( nNextOutlineId, nProfileType == WIN_PRF.SPLIT) - -- creo copie di profilo e controprofili + -- recupero profilo principale e ne creo copia + local nOrigMainProfileId = GetOutlineProfileId( nOutlineId, nProfileType == WIN_PRF.BOTTOMRAIL) local nMainProfileId = EgtCopy( nOrigMainProfileId, nProfileLayerId) local sMainProfileType = EgtGetName( nMainProfileId) EgtSetInfo( nMainProfileId, WIN_PRF_TYPE, sMainProfileType) EgtSetName( nMainProfileId, WIN_PRF_MAIN) - local nStartProfileId = EgtCopy( nOrigStartProfileId, nProfileLayerId) - local sStartProfileType = EgtGetName( nStartProfileId) - EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType) - EgtSetName( nStartProfileId, WIN_PRF_START) - local nEndProfileId = EgtCopy( nOrigEndProfileId, nProfileLayerId) - local sEndProfileType = EgtGetName( nEndProfileId) - EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType) - EgtSetName( nEndProfileId, WIN_PRF_END) + -- recupero controprofili start e ne creo copia + for i = 1, #vPrevOutlineId do + -- se il tipo corrente è split il pezzo va tagliato con il bottomrail, altrimenti con il bottom + local nOrigStartProfileId = GetOutlineProfileId( vPrevOutlineId[i], nProfileType == WIN_PRF.SPLIT) + local nStartProfileId = EgtCopy( nOrigStartProfileId, nProfileLayerId) + local sStartProfileType = EgtGetName( nStartProfileId) + EgtSetInfo( nStartProfileId, WIN_PRF_TYPE, sStartProfileType) + EgtSetName( nStartProfileId, WIN_PRF_START) + end + + -- recupero controprofili end e ne creo copia + for i = 1, #vNextOutlineId do + local nOrigEndProfileId = GetOutlineProfileId( vNextOutlineId[i], nProfileType == WIN_PRF.SPLIT) + local nEndProfileId = EgtCopy( nOrigEndProfileId, nProfileLayerId) + local sEndProfileType = EgtGetName( nEndProfileId) + EgtSetInfo( nEndProfileId, WIN_PRF_TYPE, sEndProfileType) + EgtSetName( nEndProfileId, WIN_PRF_END) + end + -- recupero le info di pinzaggio dal profilo di estrusione CopyInfo( nPartId, nMainProfileId, WIN_PRC_OFFY_1) CopyInfo( nPartId, nMainProfileId, WIN_PRC_OFFZ_1) @@ -875,7 +906,7 @@ end --------------------------------------------------------------------- -- funzione che crea le curve del geo -local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId) +local function CreateFrameGeo( nOutlineId, vPrevOutlineId, vNextOutlineId, nStartPartJointType, nEndPartJointType, nGeoLayerId, nProfileLayerId) local nCurrProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) local nCurrProfileRefId = EgtGetFirstNameInGroup( nCurrProfileId, WIN_REF) @@ -901,68 +932,69 @@ local function CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStar local nSemiProfileIn = EgtGetFirstNameInGroup( nCurrProfileId, WIN_IN) or EgtGetFirstNameInGroup( nCurrProfileId, WIN_IN .. '2') EgtSetInfo( nCurrOffsetId, WIN_SEMI_PROFILE, nSemiProfileIn) - -- curva left - local nPrevCurveId - local nPrevSemiProfile - if nStartPartJointType == WIN_PART_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) - local nPrevProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) - if nStartPartJointType == WIN_PART_JNT.SHORT then - local sCtrIn = GetProfileCtrIn( nProfileType, nPrevOutlineId, nOutlineId, nPrevProfileId) - local dPrevCPDelta = GetDeltaProfile( nPrevProfileId, sCtrIn) - EgtOffsetCurve( nPrevCurveId, - dPrevCPDelta) - EgtSetInfo( nGeoLayerId, WIN_STARTCPDELTA, dPrevCPDelta) - -- ricavo il semiprofilo associato - nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, sCtrIn) + -- curve left + for i = 1, #vPrevOutlineId do + local nPrevCurveId + local nPrevSemiProfile + if nStartPartJointType == WIN_PART_JNT.ANGLED then + -- calcolo la bisettrice + local vtMedia = ( ( EgtSV( nOutlineId) - EgtEV( vPrevOutlineId[i])) / 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 - nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, WIN_OUT) + nPrevCurveId = EgtCopy( vPrevOutlineId[i], nGeoLayerId) + local nPrevProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) + if nStartPartJointType == WIN_PART_JNT.SHORT then + local sCtrIn = GetProfileCtrIn( vPrevOutlineId[i], nOutlineId, nPrevProfileId) + local dPrevCPDelta = GetDeltaProfile( nPrevProfileId, sCtrIn) + EgtOffsetCurve( nPrevCurveId, - dPrevCPDelta) + EgtSetInfo( nGeoLayerId, WIN_STARTCPDELTA, dPrevCPDelta) + -- ricavo il semiprofilo associato + nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, sCtrIn) + else + nPrevSemiProfile = EgtGetFirstNameInGroup( nPrevProfileId, WIN_OUT) + end end + EgtSetName( nPrevCurveId, WIN_GEO_LEFT) + EgtSetInfo( nPrevCurveId, WIN_SEMI_PROFILE, nPrevSemiProfile) + EgtRelocateGlob( nPrevCurveId, nGeoLayerId, GDB_IN.LAST_SON) end - EgtSetName( nPrevCurveId, WIN_GEO_LEFT) - EgtSetInfo( nPrevCurveId, WIN_SEMI_PROFILE, nPrevSemiProfile) - -- curva right - local nNextCurveId - local nNextSemiProfile - if nEndPartJointType == WIN_PART_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()) - else - nNextCurveId = EgtCopy( nNextOutlineId, nGeoLayerId) - local nNextProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) - if nEndPartJointType == WIN_PART_JNT.SHORT then - local sCtrIn = GetProfileCtrIn( nProfileType, nNextOutlineId, nOutlineId, nNextProfileId) - local dNextCPDelta = GetDeltaProfile( nNextProfileId, sCtrIn) - EgtOffsetCurve( nNextCurveId, - dNextCPDelta) - EgtSetInfo( nGeoLayerId, WIN_ENDCPDELTA, dNextCPDelta) - -- ricavo il semiprofilo associato - nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, sCtrIn) + -- curve right + for i = 1, #vNextOutlineId do + local nNextCurveId + local nNextSemiProfile + if nEndPartJointType == WIN_PART_JNT.ANGLED then + -- calcolo la bisettrice + local vtMedia = ( ( EgtSV( vNextOutlineId[i]) - 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()) else - nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, WIN_OUT) + nNextCurveId = EgtCopy( vNextOutlineId[i], nGeoLayerId) + local nNextProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) + if nEndPartJointType == WIN_PART_JNT.SHORT then + local sCtrIn = GetProfileCtrIn( vNextOutlineId[i], nOutlineId, nNextProfileId) + local dNextCPDelta = GetDeltaProfile( nNextProfileId, sCtrIn) + EgtOffsetCurve( nNextCurveId, - dNextCPDelta) + EgtSetInfo( nGeoLayerId, WIN_ENDCPDELTA, dNextCPDelta) + -- ricavo il semiprofilo associato + nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, sCtrIn) + else + nNextSemiProfile = EgtGetFirstNameInGroup( nNextProfileId, WIN_OUT) + end end + EgtSetName( nNextCurveId, WIN_GEO_RIGHT) + EgtSetInfo( nNextCurveId, WIN_SEMI_PROFILE, nNextSemiProfile) + EgtRelocateGlob( nNextCurveId, nCurrOffsetId, GDB_IN.BEFORE) end - EgtSetName( nNextCurveId, WIN_GEO_RIGHT) - EgtSetInfo( nNextCurveId, WIN_SEMI_PROFILE, nNextSemiProfile) - - -- riordino le curve per eseguire correttamente il trim - EgtRelocateGlob( nNextCurveId, nCurrCurveId, GDB_IN.AFTER) - EgtRelocateGlob( nCurrOffsetId, nNextCurveId, GDB_IN.AFTER) - EgtRelocateGlob( nPrevCurveId, nCurrOffsetId, GDB_IN.AFTER) - + -- trim delle curve TrimAndOrientOrderedCurveLayer( nGeoLayerId) @@ -1017,8 +1049,8 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType) local nGeoLayerId = EgtGroup( nPartId) EgtSetName( nGeoLayerId, WIN_GEO) - -- recupero outline precedente e successivo - local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) + -- recupero outline precedenti e successivi ( solo nel caso di split possono essere più di uno) + local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) -- recupero il tipo di giunzioni local nStartJointType @@ -1033,19 +1065,20 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType) nStartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TL, 'i') nEndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BL, 'i') elseif nProfileType == WIN_PRF.RIGHT then - -- recupero tipo di giunzioni nStartJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_BR, 'i') nEndJointType = EgtGetInfo( nOutlineLayerId, WIN_JOINT_TR, 'i') else -- nei casi di profilo BottomRail e Split non serve settare dei valori per StartJointType ed EndJointType perchè -- in CalcPartJointType la loro giunzione viene settata a short end - -- se pezzo non e' split, giunzione diversa da bisettrice ed arco a tutto sesto forzo il tipo a bisettrice - if nProfileType ~= WIN_PRF.SPLIT and nStartJointType ~= WIN_JNT.ANGLED and AreSameVectorApprox( EgtEV( nPrevOutlineId), EgtSV( nOutlineId)) then - nStartJointType = WIN_JNT.ANGLED + -- se pezzo non e' split, giunzione diversa da bisettrice e arco a tutto sesto oppure elementi entrambi top, forzo il tipo a bisettrice + if nProfileType ~= WIN_PRF.SPLIT and nStartJointType ~= WIN_JNT.ANGLED and + ( AreSameVectorApprox( EgtEV( vPrevOutlineId[1]), EgtSV( nOutlineId)) or EgtGetName( nOutlineId) == EgtGetName( vPrevOutlineId[1])) then + nStartJointType = WIN_JNT.ANGLED end - if nProfileType ~= WIN_PRF.SPLIT and nEndJointType ~= WIN_JNT.ANGLED and AreSameVectorApprox( EgtEV( nOutlineId), EgtSV( nNextOutlineId)) then - nEndJointType = WIN_JNT.ANGLED + if nProfileType ~= WIN_PRF.SPLIT and nEndJointType ~= WIN_JNT.ANGLED and + ( AreSameVectorApprox( EgtEV( nOutlineId), EgtSV( vNextOutlineId[1])) or EgtGetName( nOutlineId) == EgtGetName( vNextOutlineId[1])) then + nEndJointType = WIN_JNT.ANGLED end -- calcolo il tipo di giunzione per la parte @@ -1057,10 +1090,10 @@ local function CalcFrameGeo( nPartId, nOutlineId, nOutlineLayerId, nProfileType) EgtSetInfo( nOutlineId, WIN_ENDJOINT, nEndPartJointType) -- creo il gruppo con i profili del pezzo - local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, nPrevOutlineId, nNextOutlineId, nProfileType) + local nProfileLayerId = CalcFrameProfiles( nPartId, nOutlineId, vPrevOutlineId, vNextOutlineId, nProfileType) -- creo lati dell'outline - local nGeoOutId = CreateFrameGeo( nOutlineId, nPrevOutlineId, nNextOutlineId, nStartPartJointType, nEndPartJointType, nProfileType, nGeoLayerId, nProfileLayerId) + local nGeoOutId = CreateFrameGeo( nOutlineId, vPrevOutlineId, vNextOutlineId, nStartPartJointType, nEndPartJointType, nGeoLayerId, nProfileLayerId) -- calcolo le lavorazioni associate ai profili CalcProfilingProcessings( nPartId, nGeoLayerId) @@ -1512,7 +1545,7 @@ end local function CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType) -- creo fori per spine su Start ed End - local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) + local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( nProfileType, nOutlineId, nOutlineLayerId) local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) local nProcLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PRC) local nGeoLayerId = EgtGetFirstNameInGroup( nPartId, WIN_GEO) @@ -1521,8 +1554,12 @@ local function CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileTy local nSolidLayerId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) nMainExtrusionId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_SRF_MAIN) end - AddStartDowels( nOutlineId, nPrevOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) - AddEndDowels( nOutlineId, nNextOutlineId, nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) + for i = 1, #vPrevOutlineId do + AddStartDowels( nOutlineId, vPrevOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) + end + for i = 1, #vNextOutlineId do + AddEndDowels( nOutlineId, vNextOutlineId[i], nProfileLayerId, nProcLayerId, nGeoLayerId, nMainExtrusionId) + end -- split dowels AddSplitDowels( nOutlineId, nOutlineLayerId, nPartId, nProfileType) @@ -1533,40 +1570,46 @@ end ---------------------------------- SOLIDO ---------------------------------------- ---------------------------------------------------------------------------------- -- funzione che recupera tipo di inizio e fine pezzo -local function CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId) +local function CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileId, vEndProfileId) - local sStartProfileType - local sEndProfileType - local StartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i') - if StartJointType == WIN_PART_JNT.ANGLED then - sStartProfileType = WIN_MINIZINKEN - elseif StartJointType == WIN_PART_JNT.SHORT then - sStartProfileType = WIN_CTRINOFST - elseif StartJointType == WIN_PART_JNT.FULL then - sStartProfileType = WIN_OUTOFST - end - - local EndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i') - if EndJointType == WIN_PART_JNT.ANGLED then - sEndProfileType = WIN_MINIZINKEN - elseif EndJointType == WIN_PART_JNT.SHORT then - sEndProfileType = WIN_CTRINOFST - elseif EndJointType == WIN_PART_JNT.FULL then - sEndProfileType = WIN_OUTOFST - end + local vsStartProfileType = {} + local vsEndProfileType = {} if nProfileType == WIN_PRF.SPLIT then - local nStartBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i') - local nStartId = EgtGetInfo( nStartBaseOutlineId, WIN_COPY, 'i') - local nEndBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i') - local nEndId = EgtGetInfo( nEndBaseOutlineId, WIN_COPY, 'i') - sStartProfileType = GetProfileCtrIn( nProfileType, nStartId, nOutlineId, nStartProfileId) - sEndProfileType = GetProfileCtrIn( nProfileType, nEndId, nOutlineId, nEndProfileId) - sStartProfileType = WIN_OFST .. sStartProfileType - sEndProfileType = WIN_OFST .. sEndProfileType + local vStartBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'vi') + for i = 1, #vStartBaseOutlineId do + local nStartId = EgtGetInfo( vStartBaseOutlineId[i], WIN_COPY, 'i') + local sStartProfileType = GetProfileCtrIn( nStartId, nOutlineId, vStartProfileId[i]) + table.insert( vsStartProfileType, WIN_OFST .. sStartProfileType) + end + local vEndBaseOutlineId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'vi') + for i = 1, #vEndBaseOutlineId do + local nEndId = EgtGetInfo( vEndBaseOutlineId[i], WIN_COPY, 'i') + local sEndProfileType = GetProfileCtrIn( nEndId, nOutlineId, vEndProfileId[i]) + table.insert( vsEndProfileType, WIN_OFST .. sEndProfileType) + end + + else + local StartJointType = EgtGetInfo( nOutlineId, WIN_STARTJOINT, 'i') + if StartJointType == WIN_PART_JNT.ANGLED then + vsStartProfileType = { WIN_MINIZINKEN} + elseif StartJointType == WIN_PART_JNT.SHORT then + vsStartProfileType = { WIN_CTRINOFST} + elseif StartJointType == WIN_PART_JNT.FULL then + vsStartProfileType = { WIN_OUTOFST} + end + + local EndJointType = EgtGetInfo( nOutlineId, WIN_ENDJOINT, 'i') + if EndJointType == WIN_PART_JNT.ANGLED then + vsEndProfileType = { WIN_MINIZINKEN} + elseif EndJointType == WIN_PART_JNT.SHORT then + vsEndProfileType = { WIN_CTRINOFST} + elseif EndJointType == WIN_PART_JNT.FULL then + vsEndProfileType = { WIN_OUTOFST} + end end - - return sStartProfileType, sEndProfileType + + return vsStartProfileType, vsEndProfileType end --------------------------------------------------------------------- @@ -1583,18 +1626,26 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) -- recupero profili e controprofili local nProfileLayerId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_MAIN) - local nStartProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_START) - local nEndProfileId = EgtGetFirstNameInGroup( nProfileLayerId, WIN_PRF_END) + local vStartProfileId = EgtGetNameInGroup( nProfileLayerId, WIN_PRF_START) + local vEndProfileId = EgtGetNameInGroup( nProfileLayerId, WIN_PRF_END) -- recupero geo local nGeoLayerId = EgtGetParent( nGeoId) - local nPrevGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_LEFT) - local nNextGeoId = EgtGetFirstNameInGroup( nGeoLayerId, WIN_GEO_RIGHT) + local vPrevGeoId = EgtGetNameInGroup( nGeoLayerId, WIN_GEO_LEFT) + local vNextGeoId = EgtGetNameInGroup( nGeoLayerId, WIN_GEO_RIGHT) -- recupero BBox e larghezza del geo local dGeoWidth = EgtGetInfo( nGeoId, WIN_GEOWIDTH, 'd') -- recupero i controprofili in base al tipo di giunzioni - local sStartProfileType, sEndProfileType = CalcStartEndProfileType( nProfileType, nOutlineId, nStartProfileId, nEndProfileId) + local vsStartProfileType, vsEndProfileType = CalcStartEndProfileType( nProfileType, nOutlineId, vStartProfileId, vEndProfileId) + + -- verifico se outline è split interno ad area di split per controlli su inversione del profilo + local bSplitInsideSplitArea = false + if nProfileType == WIN_PRF.SPLIT then + local nAreaId = EgtGetParent( EgtGetParent( nOutlineId)) + local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') + bSplitInsideSplitArea = ( nAreaType == WIN_AREATYPES.SPLIT) + end -- a) MAIN EXTRUSION -- creo guida Main @@ -1622,132 +1673,128 @@ local function CalcFrameSolid( nPartId, nOutlineId, nGeoId, nProfileType) -- b) START PROFILE - -- 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))) - - -- verifico se outline è split interno ad area di split per controlli su inversione del profilo - local bSplitInsideSplitArea = false - if nProfileType == WIN_PRF.SPLIT then - local nAreaId = EgtGetParent( EgtGetParent( nOutlineId)) - local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') - bSplitInsideSplitArea = ( nAreaType == WIN_AREATYPES.SPLIT) - end - - if bSplitInsideSplitArea then - -- verifico se il suo start deriva da uno split - local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i') - local nStartSouId = nStartId - local sStartSouName - repeat - nStartSouId = EgtGetInfo( nStartSouId, WIN_SOU, 'i') - sStartSouName = EgtGetName( nStartSouId or GDB_ID.NULL) - until not nStartSouId or sStartSouName == WIN_SPLIT - if sStartSouName == WIN_SPLIT then - -- recupero vettore tangente nel punto medio della curva di contorno - local ptMidStart = EgtMP( nStartId) - local vtMidStart = EgtMV( nStartId) - -- recupero vettore tangente nello stesso punto della curva split originale - local dMidStartOnStartSou = EgtCurveParamAtPoint( nStartSouId, ptMidStart) - local vtMidStartSou = EgtUV( nStartSouId, dMidStartOnStartSou, -1) - -- se i due vettori non sono orientati nella stessa direzione - if not AreSameVectorApprox( vtMidStart, vtMidStartSou) then - -- ruoto di 180 gradi il profilo - local frStartProfileS = EgtFR( nStartProfileFrameId, GDB_ID.ROOT) - EgtRotate( nStartProfileId, frStartProfileS:getOrigin(), frStartProfileS:getVersY(), 180, GDB_RT.GLOB) + for i = 1, #vPrevGeoId do + -- posiziono il profilo Start + local nRefStartProfileId = EgtGetFirstNameInGroup( vStartProfileId[i], 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( vPrevGeoId[i], nSolidLayerId) + EgtExtendCurveStartByLen( nStartGuideId, 2 * dGeoWidth) + EgtExtendCurveEndByLen( nStartGuideId, 2 * dGeoWidth) + -- recupero frame del profilo + local nStartProfileFrameId = EgtGetFirstNameInGroup( vStartProfileId[i], 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( vStartProfileId[i]), frStartProfile) + -- assegno come riferimento del profilo il punto start dell'outline + EgtChangeGroupFrame( vStartProfileId[i], Frame3d( EgtSP( nStartGuideId), - EgtSV( nStartGuideId))) + + if bSplitInsideSplitArea then + -- verifico se il suo start deriva da uno split + local nStartId = EgtGetInfo( nOutlineId, WIN_SPLIT_STARTINTERS, 'i') + local nStartSouId = nStartId + local sStartSouName + repeat + nStartSouId = EgtGetInfo( nStartSouId, WIN_SOU, 'i') + sStartSouName = EgtGetName( nStartSouId or GDB_ID.NULL) + until not nStartSouId or sStartSouName == WIN_SPLIT + if sStartSouName == WIN_SPLIT then + -- recupero vettore tangente nel punto medio della curva di contorno + local ptMidStart = EgtMP( nStartId) + local vtMidStart = EgtMV( nStartId) + -- recupero vettore tangente nello stesso punto della curva split originale + local dMidStartOnStartSou = EgtCurveParamAtPoint( nStartSouId, ptMidStart) + local vtMidStartSou = EgtUV( nStartSouId, dMidStartOnStartSou, -1) + -- se i due vettori non sono orientati nella stessa direzione + if not AreSameVectorApprox( vtMidStart, vtMidStartSou) then + -- ruoto di 180 gradi il profilo + local frStartProfileS = EgtFR( nStartProfileFrameId, GDB_ID.ROOT) + EgtRotate( vStartProfileId[i], frStartProfileS:getOrigin(), frStartProfileS:getVersY(), 180, GDB_RT.GLOB) + end end end + + -- recupero outline del profilo Start e lo estrudo + local nOutStartProfileId + if vsStartProfileType[i] == WIN_MINIZINKEN then + nOutStartProfileId = EgtLine( vStartProfileId[i], EgtSP( vPrevGeoId[i]), EgtSP( vPrevGeoId[i]) - Z_AX() * b3RefStartProfile:getDimY(), GDB_RT.GLOB) + EgtInvertCurve( nOutStartProfileId) + else + nOutStartProfileId = EgtGetFirstNameInGroup( vStartProfileId[i], vsStartProfileType[i]) + end + local nStartExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutStartProfileId, nStartGuideId, false, WIN_SURF_APPROX) + -- eseguo intersezione per ottenere un solido unico + -- ( tagliare le due superfici con EgtSurfTmCut e poi unirle potrebbe creare piccoli buchi legati alle diverse approssimazioni) + EgtSurfTmIntersect( nMainExtrusionId, nStartExtrusionId) + EgtErase( nStartExtrusionId) + EgtErase( nStartGuideId) end - -- 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, WIN_SURF_APPROX) - -- eseguo intersezione per ottenere un solido unico - -- ( tagliare le due superfici con EgtSurfTmCut e poi unirle potrebbe creare piccoli buchi legati alle diverse approssimazioni) - EgtSurfTmIntersect( nMainExtrusionId, nStartExtrusionId) - EgtErase( nStartExtrusionId) - EgtErase( nStartGuideId) - -- c) END PROFILE - -- 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))) - - -- verifico se necessario ruotare di 180 gradi il profilo - if bSplitInsideSplitArea then - -- verifico se end deriva da split - local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i') - local nEndSouId = nEndId - local sEndSouName - repeat - nEndSouId = EgtGetInfo( nEndSouId, WIN_SOU) - sEndSouName = EgtGetName( nEndSouId or GDB_ID.NULL) - until not nEndSouId or sEndSouName == WIN_SPLIT - if sEndSouName == WIN_SPLIT then - -- recupero vettore tangente nel punto medio della curva di contorno - local ptMidEnd = EgtMP( nEndId) - local vtMidEnd = EgtMV( nEndId) - -- recupero vettore tangente nello stesso punto della curva split originale - local dMidStartOnEndSou = EgtCurveParamAtPoint( nEndSouId, ptMidEnd) - local vtMidEndSou = EgtUV( nEndSouId, dMidStartOnEndSou, -1) - -- se i due vettori non sono orientati nella stessa direzione - if not AreSameVectorApprox( vtMidEnd, vtMidEndSou) then - -- ruoto di 180 gradi il profilo - local frEndProfileS = EgtFR( nEndProfileFrameId, GDB_ID.ROOT) - EgtRotate( nEndProfileId, frEndProfileS:getOrigin(), frEndProfileS:getVersY(), 180, GDB_RT.GLOB) + for i = 1, #vNextGeoId do + -- posiziono il profilo End + local nRefEndProfileId = EgtGetFirstNameInGroup( vEndProfileId[i], 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( vNextGeoId[i], nSolidLayerId) + EgtExtendCurveStartByLen( nEndGuideId, 2 * dGeoWidth) + EgtExtendCurveEndByLen( nEndGuideId, 2 * dGeoWidth) + -- recupero frame del profilo + local nEndProfileFrameId = EgtGetFirstNameInGroup( vEndProfileId[i], WIN_SECTIONFRAME) + local frEndProfile = EgtFR( nEndProfileFrameId) + frEndProfile:move( - frEndProfile:getVersX() * dEndDelta) + frEndProfile:invert() + -- lo applico a tutte le geometrie del profilo + EgtTransform( EgtGetAllInGroup( vEndProfileId[i]), frEndProfile) + -- assegno come riferimento del profilo il punto start dell'outline + EgtChangeGroupFrame( vEndProfileId[i], Frame3d( EgtSP( nEndGuideId), - EgtSV( nEndGuideId))) + + -- verifico se necessario ruotare di 180 gradi il profilo + if bSplitInsideSplitArea then + -- verifico se end deriva da split + local nEndId = EgtGetInfo( nOutlineId, WIN_SPLIT_ENDINTERS, 'i') + local nEndSouId = nEndId + local sEndSouName + repeat + nEndSouId = EgtGetInfo( nEndSouId, WIN_SOU) + sEndSouName = EgtGetName( nEndSouId or GDB_ID.NULL) + until not nEndSouId or sEndSouName == WIN_SPLIT + if sEndSouName == WIN_SPLIT then + -- recupero vettore tangente nel punto medio della curva di contorno + local ptMidEnd = EgtMP( nEndId) + local vtMidEnd = EgtMV( nEndId) + -- recupero vettore tangente nello stesso punto della curva split originale + local dMidStartOnEndSou = EgtCurveParamAtPoint( nEndSouId, ptMidEnd) + local vtMidEndSou = EgtUV( nEndSouId, dMidStartOnEndSou, -1) + -- se i due vettori non sono orientati nella stessa direzione + if not AreSameVectorApprox( vtMidEnd, vtMidEndSou) then + -- ruoto di 180 gradi il profilo + local frEndProfileS = EgtFR( nEndProfileFrameId, GDB_ID.ROOT) + EgtRotate( vEndProfileId[i], frEndProfileS:getOrigin(), frEndProfileS:getVersY(), 180, GDB_RT.GLOB) + end end end + + -- recupero outline del profilo End e lo estrudo + local nOutEndProfileId + if vsEndProfileType[i] == WIN_MINIZINKEN then + nOutEndProfileId = EgtLine( vEndProfileId[i], EgtSP( vNextGeoId[i]), EgtSP( vNextGeoId[i]) - Z_AX() * b3RefEndProfile:getDimY(), GDB_RT.GLOB) + EgtInvertCurve( nOutEndProfileId) + else + nOutEndProfileId = EgtGetFirstNameInGroup( vEndProfileId[i], vsEndProfileType[i]) + end + local nEndExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutEndProfileId, nEndGuideId, false, WIN_SURF_APPROX) + -- eseguo intersezione per ottenere un solido unico + EgtSurfTmIntersect( nMainExtrusionId, nEndExtrusionId) + EgtErase( nEndExtrusionId) + EgtErase( nEndGuideId) end - - -- 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) - EgtInvertCurve( nOutEndProfileId) - else - nOutEndProfileId = EgtGetFirstNameInGroup( nEndProfileId, sEndProfileType) - end - local nEndExtrusionId = EgtSurfTmSwept( nSolidLayerId, nOutEndProfileId, nEndGuideId, false, WIN_SURF_APPROX) - -- eseguo intersezione per ottenere un solido unico - EgtSurfTmIntersect( nMainExtrusionId, nEndExtrusionId) - EgtErase( nEndExtrusionId) - EgtErase( nEndGuideId) end @@ -1807,7 +1854,6 @@ local function CreatePartFromOutline( nAreaLayerId, nOutlineId, bBottomRail) -- calcolo i fori per le spine CalcFrameDowels( nPartId, nOutlineId, nOutlineLayerId, nProfileType) - -- b) Fill elseif nAreaType == WIN_AREATYPES.FILL then -- imposto nome del pezzo @@ -1837,30 +1883,29 @@ end ---------------------------- STRIP ---------------------------------- --------------------------------------------------------------------- -- funzione che restitutisce lo Strip piu' vicino -local function GetStripNearestToOutline( nProfileId, nOutlineId) - -- recupero strip - local ptStartOutline = EgtMP( nOutlineId) - local vtStartOutline = EgtSV( nOutlineId) - local nStartStripId = EgtGetFirstNameInGroup( nProfileId, WIN_STRIP) - if not nStartStripId then - local nStripMinDistId - local dMinDistance - local nStripId = EgtGetFirstNameInGroup( nProfileId, WIN_STRIP .. '*') - while nStripId do - local b3Strip = EgtGetBBoxGlob( nStripId, GDB_BB.STANDARD) - -- calcolo il vettore distanza - local vtDistance = b3Strip:getCenter() - ptStartOutline - -- ne ricavo la componente nella stessa direzione dell'outline - local dDistance = abs( vtDistance * vtStartOutline) - if not dMinDistance or dDistance < dMinDistance then - dMinDistance = dDistance - nStripMinDistId = nStripId - end - nStripId = EgtGetNextName( nStripId, WIN_STRIP .. '*') +-- ( analoga a GetProfileCtrIn) +local function GetStripNearestToOutline( nPrevProfileId, nPrevOutlineId, nOutlineId) + local nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP) + -- gestione particolare del caso di profilo di split + if not nStripId then + -- recupero la curva di base outline da cui deriva il precedente + local nPrevSouId = EgtGetInfo( nPrevOutlineId, WIN_COPY, 'i') + local sPrevSouName + repeat + nPrevSouId = EgtGetInfo( nPrevSouId, WIN_SOU, 'i') + sPrevSouName = EgtGetName( nPrevSouId or GDB_ID.NULL) + until not nPrevSouId or sPrevSouName == WIN_SPLIT + + -- verifico da quale lato si trova la curva per decidere quale controprofilo considerare + local _, _, dSide = EgtPointCurveDistSide( EgtMP( nOutlineId), nPrevSouId, Z_AX()) + if dSide == 1 then + nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '1') -- dx + else + nStripId = EgtGetFirstNameInGroup( nPrevProfileId, WIN_STRIP .. '2') -- sx end - nStartStripId = nStripMinDistId end - return nStartStripId + + return nStripId end --------------------------------------------------------------------- @@ -1885,7 +1930,7 @@ local function CreateStripGuideLines( nOutlineId, nStripId, nProfileId, nSolidLa EgtOffsetCurve( nStripMaxOffsetId, dMainStripMaxDelta) return nStripMinOffsetId, nStripMaxOffsetId - + end --------------------------------------------------------------------- @@ -1924,7 +1969,10 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) -- recupero gli outline precedente e successivo ( non serve utilizzare un WIN_PRF accurato perchè conta solo sia diverso da split) local nOutlineLayerId = EgtGetParent( nOutlineId) - local nPrevOutlineId, nNextOutlineId = GetPrevNextOutline( WIN_PRF.NULL, nOutlineId, nOutlineLayerId) + local vPrevOutlineId, vNextOutlineId = GetPrevNextOutline( WIN_PRF.NULL, nOutlineId, nOutlineLayerId) + local nPrevOutlineId = vPrevOutlineId[1] + local nNextOutlineId = vNextOutlineId[1] + -- recupero i pezzi precedente e successivo, prendendo eventualmente quelli di bottomrail local nPrevPartId = FindAssociatedPart( nPrevOutlineId) local nNextPartId = FindAssociatedPart( nNextOutlineId) @@ -1940,20 +1988,20 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) -- recupero guida Main local nGuideId = EgtGetFirstNameInGroup( nSolidLayerId, WIN_MAINGUIDE) -- recupero strip piu' vicino a prev outline - local nMainStripId = GetStripNearestToOutline( nMainProfileId, nPrevOutlineId) + local nMainStripId = GetStripNearestToOutline( nMainProfileId, nOutlineId, nPrevOutlineId) -- estrudo MainStrip local nMainStripExtrusionId = EgtSurfTmSwept( nSolidLayerId, nMainStripId, nGuideId, false, WIN_SURF_APPROX) EgtSetName( nMainStripExtrusionId, WIN_SRF_STRIP) -- b) taglio con start -- recupero strip dello start piu' vicino ad outline - local nStartStripId = GetStripNearestToOutline( nStartProfileId, nOutlineId) + local nStartStripId = GetStripNearestToOutline( nStartProfileId, nPrevOutlineId, nOutlineId) -- disegno guida start per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip e StartStrip local nMainStripMinOffsetId, nMainStripMaxOffsetId = CreateStripGuideLines( nOutlineId, nMainStripId, nMainProfileId, nSolidLayerId) local nStartStripMinOffsetId, nStartStripMaxOffsetId = CreateStripGuideLines( nPrevOutlineId, nStartStripId, nStartProfileId, nSolidLayerId) - local ptStripMinStart = EgtIP( nMainStripMinOffsetId, nStartStripMinOffsetId, EgtSP( nMainStripMinOffsetId)) - local ptStripMaxStart = EgtIP( nMainStripMaxOffsetId, nStartStripMaxOffsetId, EgtSP( nMainStripMaxOffsetId)) + local ptStripMinStart = FindIntersectionPoint( nMainStripMinOffsetId, nStartStripMinOffsetId) + local ptStripMaxStart = FindIntersectionPoint( nMainStripMaxOffsetId, nStartStripMaxOffsetId) local nStartStripGuideId = EgtLine( nSolidLayerId, ptStripMinStart, ptStripMaxStart) EgtExtendCurveStartByLen( nStartStripGuideId, 10) EgtExtendCurveEndByLen( nStartStripGuideId, 10) @@ -1972,12 +2020,12 @@ local function CreateStripFromOutline( nAreaId, nOutlineId) -- c) taglio con end -- recupero strip piu' vicino ad outline - local nEndStripId = GetStripNearestToOutline( nEndProfileId, nOutlineId) + local nEndStripId = GetStripNearestToOutline( nEndProfileId, nNextOutlineId, nOutlineId) -- disegno guida end per lo strip trovando le intersezioni degli outline minimi e massimi tra MainStrip ed EndStrip local nEndStripMinOffsetId, nEndStripMaxOffsetId = CreateStripGuideLines( nNextOutlineId, nEndStripId, nEndProfileId, nSolidLayerId) - local ptStripMinEnd = EgtIP( nMainStripMinOffsetId, nEndStripMinOffsetId, EgtSP( nMainStripMinOffsetId)) - local ptStripMaxEnd = EgtIP( nMainStripMaxOffsetId, nEndStripMaxOffsetId, EgtSP( nMainStripMaxOffsetId)) + local ptStripMinEnd = FindIntersectionPoint( nMainStripMinOffsetId, nEndStripMinOffsetId) + local ptStripMaxEnd = FindIntersectionPoint( nMainStripMaxOffsetId, nEndStripMaxOffsetId) local nEndStripGuideId = EgtLine( nSolidLayerId, ptStripMinEnd, ptStripMaxEnd) EgtExtendCurveStartByLen( nEndStripGuideId, 10) EgtExtendCurveEndByLen( nEndStripGuideId, 10) @@ -2069,7 +2117,7 @@ local function CalculateAreaParts( nAreaId) end end end - + -- disegno area di selezione per programma local nSelectionLayerId = EgtGroup( nAreaId) EgtSetName( nSelectionLayerId, WIN_SELECTION) diff --git a/Profiles/WinLib/WinCreate.lua b/Profiles/WinLib/WinCreate.lua index 50aa5db..3de3894 100644 --- a/Profiles/WinLib/WinCreate.lua +++ b/Profiles/WinLib/WinCreate.lua @@ -59,73 +59,141 @@ function WinCreate.ImportProfile( sProfilePath) return true end --- funzione che crea il buco rettangolare per la finestra -function WinCreate.CreateFrame( dWidth, dHeight, nJointBL, nJointBR, nJointTR, nJointTL) +---------------------------------------------------------------------------------- +------------------------------------- TELAIO ------------------------------------- +---------------------------------------------------------------------------------- +-- funzione che crea il buco per la finestra a partire da curve generiche +-- TO DO rendere i joints un vettore con un numero variabile a seconda del tipo di finestra +function WinCreate.CreateGenFrame( vFrameCrvs, nJointBL, nJointBR, nJointTL, nJointTR) -- creo gruppo per telaio local nFrameAreaId = EgtGroup( GDB_ID.ROOT) EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')') -- imposto il tipo EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME) + -- creo il gruppo con le curve di outline local nAreaOutlineLayerId = EgtGroup( nFrameAreaId) EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE) - EgtSetStatus( nAreaOutlineLayerId, GDB_ST.OFF) - -- disegno outline - local nFrameBottomId = EgtLine( nAreaOutlineLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) - EgtSetName( nFrameBottomId, WIN_BOTTOM) - local nFrameRightId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0)) - EgtSetName( nFrameRightId, WIN_RIGHT) - local nFrameTopId = EgtLine( nAreaOutlineLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0)) - EgtSetName( nFrameTopId, WIN_TOP) - local nFrameLeftId = EgtLine( nAreaOutlineLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) - EgtSetName( nFrameLeftId, WIN_LEFT) + for i = 1, #vFrameCrvs do + EgtRelocateGlob( vFrameCrvs[i], nAreaOutlineLayerId) + end -- imposto tipo giunzioni EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL) EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR) EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL) EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR) - return nFrameAreaId + + return nFrameAreaId end --- funzione che crea il buco per la finestra -function WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, nJointBL, nJointBR, nJointTR, nJointTL) - -- creo gruppo per telaio - local nFrameAreaId = EgtGroup( GDB_ID.ROOT) - EgtSetName( nFrameAreaId, WIN_AREA .. '(' .. WIN_FRAME .. ')') - -- imposto il tipo - EgtSetInfo( nFrameAreaId, WIN_AREATYPE, WIN_AREATYPES.FRAME) - local nAreaOutlineLayerId = EgtGroup( nFrameAreaId) - EgtSetName( nAreaOutlineLayerId, WIN_AREAOUTLINE) + +---------------------------------------------------------------------------------- +-- funzione che crea le curve che definiscono il telaio in base alla geometria richiesta +local function CreateFrameCurves( nLayerId, nType, dWidth, dHeight, dVal) + + if nType == WIN_FRAME_TYPE.RECT then + -- telaio rettangolare + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTopId = EgtLine( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0, dHeight, 0)) + EgtSetName( nFrameTopId, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + elseif nType == WIN_FRAME_TYPE.CHAMFER_SIDE then + -- dHeight è l'altezza del lato sx, dVal è l'altezza del lato dx + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dVal, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTopId = EgtLine( nLayerId, Point3d( dWidth, dVal, 0), Point3d( 0, dHeight, 0)) + EgtSetName( nFrameTopId, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + + elseif nType == WIN_FRAME_TYPE.CHAMFER then + -- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTop1Id = EgtLine( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( dWidth / 2, dVal, 0)) + local nFrameTop2Id = EgtLine( nLayerId, Point3d( dWidth / 2, dVal, 0), Point3d( 0, dHeight, 0)) + EgtSetName( nFrameTop1Id, WIN_TOP) + EgtSetName( nFrameTop2Id, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + elseif nType == WIN_FRAME_TYPE.ROUND_ARC then + -- arco a tutto sesto + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight - 0.5 * dWidth, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTopId = EgtArcCPA( nLayerId, Point3d( 0.5 * dWidth, dHeight - 0.5 * dWidth, 0), Point3d( dWidth, dHeight - 0.5 * dWidth, 0), 180, 0) + EgtSetName( nFrameTopId, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight - 0.5 * dWidth, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + elseif nType == WIN_FRAME_TYPE.SEGMENTAL_ARC then + -- arco ribassato + -- dHeight è l'altezza dei lati verticali, dVal è l'altezza complessiva della finestra + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTopId = EgtArc3P( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Point3d( 0, dHeight, 0)) + EgtSetName( nFrameTopId, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + elseif nType == WIN_FRAME_TYPE.POINTED_ARC then + -- arco a tutto sesto + -- 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 + if dVal - dHeight < 0.5 * dWidth then + return + end + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dWidth, dHeight, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameTop1Id = EgtArc2PV( nLayerId, Point3d( dWidth, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Y_AX()) + EgtSetName( nFrameTop1Id, WIN_TOP) + local nFrameTop2Id = EgtArc2PV( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0.5 * dWidth, dVal, 0), Y_AX()) + EgtInvertCurve( nFrameTop2Id) + EgtSetName( nFrameTop2Id, WIN_TOP) + local nFrameLeftId = EgtLine( nLayerId, Point3d( 0, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + + elseif nType == WIN_FRAME_TYPE.TRG then + local nFrameBottomId = EgtLine( nLayerId, Point3d( 0, 0, 0), Point3d( dWidth, 0, 0)) + EgtSetName( nFrameBottomId, WIN_BOTTOM) + local nFrameRightId = EgtLine( nLayerId, Point3d( dWidth, 0, 0), Point3d( dVal, dHeight, 0)) + EgtSetName( nFrameRightId, WIN_RIGHT) + local nFrameLeftId = EgtLine( nLayerId, Point3d( dVal, dHeight, 0), Point3d( 0, 0, 0)) + EgtSetName( nFrameLeftId, WIN_LEFT) + end +end + +---------------------------------------------------------------------------------- +-- funzione che crea il telaio a partire da una specifica geometria ( rettangolo, chamfer...) +function WinCreate.CreateFrame( nType, nJointBL, nJointBR, nJointTL, nJointTR, dWidth, dHeight, dHeight2) + + -- creo un gruppo temporaneo per le curve di outline + local nTmpLay = EgtGroup( GDB_ID.ROOT) -- disegno outline - EgtRelocateGlob( nFrameBottomId, nAreaOutlineLayerId) - EgtSetName( nFrameBottomId, WIN_BOTTOM) - EgtRelocateGlob( nFrameRightId, nAreaOutlineLayerId) - EgtSetName( nFrameRightId, WIN_RIGHT) - EgtRelocateGlob( nFrameTopId, nAreaOutlineLayerId) - EgtSetName( nFrameTopId, WIN_TOP) - EgtRelocateGlob( nFrameLeftId, nAreaOutlineLayerId) - EgtSetName( nFrameLeftId, WIN_LEFT) - -- imposto tipo giunzioni - EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BL, nJointBL) - EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_BR, nJointBR) - EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TL, nJointTL) - EgtSetInfo( nAreaOutlineLayerId, WIN_JOINT_TR, nJointTR) + CreateFrameCurves( nTmpLay, nType, dWidth, dHeight, dHeight2) + local nFrameAreaId = WinCreate.CreateGenFrame( EgtGetAllInGroup( nTmpLay), nJointBL, nJointBR, nJointTL, nJointTR) + EgtErase( nTmpLay) + return nFrameAreaId end --- -- funzione che crea il telaio a partire dal buco --- function WinCreate.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 - +---------------------------------------------------------------------------------- +-------------------------------------- ANTA -------------------------------------- +---------------------------------------------------------------------------------- -- funzione che aggiunge una anta function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSashType) -- creo nuova area @@ -158,6 +226,9 @@ function WinCreate.AddSash( nAreaId, nJointBL, nJointBR, nJointTR, nJointTL, nSa return nSashAreaId end +---------------------------------------------------------------------------------- +-------------------------------------- FILL -------------------------------------- +---------------------------------------------------------------------------------- -- funzione che aggiunge un riempimento function WinCreate.AddFill( nAreaId, FillType) -- creo nuova area @@ -176,32 +247,29 @@ function WinCreate.AddFill( nAreaId, FillType) EgtSetInfo( nOutlineId, WIN_SOU, nAreaOutlineId) EgtRemoveInfo( nOutlineId, WIN_CHILD) AddInfo( nAreaOutlineId, WIN_CHILD, nOutlineId) - EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL) - EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR) - EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL) - EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TR) nAreaOutlineId = EgtGetNext( nAreaOutlineId) end + -- rimuovo eventuali info di giunzioni + EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BL) + EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_BR) + EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TL) + EgtRemoveInfo( nAreaOutlineLayerId, WIN_JOINT_TR) -- imposto tipo di fill EgtSetInfo( nFillAreaId, WIN_FILLTYPE, FillType) return nFillAreaId end +---------------------------------------------------------------------------------- +------------------------------------- SPLIT -------------------------------------- +---------------------------------------------------------------------------------- -- funzione che crea un taglio split -function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType) +function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, nProportion, nSplitType) -- creo layer temporaneo per split local nTempSplitLayerId = EgtGroup( nAreaLayerId) EgtSetName( nTempSplitLayerId, WIN_TEMPSPLIT) -- 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 nTotSplitId if SplitType == WIN_SPLITORIENTATION.VERTICAL then -- creo linea @@ -232,6 +300,7 @@ function WinCreate.AddSplit( nAreaLayerId, SplitType, MeasureType, nPosition, n return nArea1Id, nArea2Id end +---------------------------------------------------------------------------------- -- funzione che crea tagli split multipli function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList, nProportion, nSplitType) local AreaList = {} @@ -285,6 +354,7 @@ function WinCreate.AddSplits( nAreaLayerId, SplitType, MeasureType, PositionList return AreaList end +---------------------------------------------------------------------------------- -- funzione che crea un taglio split da una curva generica function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType) -- se area nulla diventa di tipo split @@ -320,8 +390,8 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType) local EndInters for nIndex = 1, #OutlineInters do local CurrOutInters = OutlineInters[nIndex] - CurrOutInters.StartDistance = (CurrOutInters.IntersPoint - ptStartSplit):sqlen() - CurrOutInters.EndDistance = (CurrOutInters.IntersPoint - ptEndSplit):sqlen() + CurrOutInters.StartDistance = dist( CurrOutInters.IntersPoint, ptStartSplit) + CurrOutInters.EndDistance = dist( CurrOutInters.IntersPoint, ptEndSplit) if not StartInters or CurrOutInters.StartDistance < StartInters.StartDistance then StartInters = CurrOutInters end @@ -334,8 +404,36 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType) 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) + + -- sistemo le info di intersezione + local dPar1 = EgtCurveParamAtPoint( StartInters.Id, StartInters.IntersPoint, 100 * GEO.EPS_SMALL) + local _, dParE1 = EgtCurveDomain( StartInters.Id) + if dPar1 < GEO.EPS_SMALL then + -- intersezione coinvolge anche curva precedente + local nOther = EgtGetPrev( StartInters.Id) or EgtGetLastInGroup( nOutlineLayerId) + EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { nOther, StartInters.Id}) + elseif abs( dPar1 - dParE1) < GEO.EPS_SMALL then + -- intersezione coinvolge anche curva successiva + local nOther = EgtGetNext( StartInters.Id) or EgtGetFirstInGroup( nOutlineLayerId) + EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { StartInters.Id, nOther}) + else + EgtSetInfo( nSplitId, WIN_SPLIT_STARTINTERS, { StartInters.Id}) + end + + local dPar2 = EgtCurveParamAtPoint( EndInters.Id, EndInters.IntersPoint, 100 * GEO.EPS_SMALL) + local _, dParE2 = EgtCurveDomain( EndInters.Id) + if dPar2 < GEO.EPS_SMALL then + -- intersezione coinvolge anche curva precedente + local nOther = EgtGetPrev( EndInters.Id) or EgtGetLastInGroup( nOutlineLayerId) + EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { nOther, EndInters.Id}) + elseif abs( dPar2 - dParE2) < GEO.EPS_SMALL then + -- intersezione coinvolge anche curva successiva + local nOther = EgtGetNext( EndInters.Id) or EgtGetFirstInGroup( nOutlineLayerId) + EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { EndInters.Id, nOther}) + else + EgtSetInfo( nSplitId, WIN_SPLIT_ENDINTERS, { EndInters.Id}) + end + -- assegno nome profilo EgtSetName( nSplitId, WIN_SPLIT) -- creo aree @@ -356,6 +454,7 @@ function WinCreate.AddGenSplit( nAreaLayerId, nSplitId, nSplitType) return nArea1Id, nArea2Id end +---------------------------------------------------------------------------------- -- funzione che crea tagli split da curve generiche function WinCreate.AddGenSplits( nAreaLayerId, SplitList) for nIndex = 1, #SplitList do @@ -363,6 +462,7 @@ function WinCreate.AddGenSplits( nAreaLayerId, SplitList) end end +---------------------------------------------------------------------------------- -- funzione che crea le aree da un taglio split function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) -- creo layer per le due aree @@ -386,13 +486,18 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) if ptInters then if nInters == 0 then -- trovato primo punto di intersezione - inizio area 2 - nInters = 1 - local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId) - EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) - EgtRemoveInfo( nCopyId, WIN_CHILD) - AddInfo( nOutlineId, WIN_CHILD, nCopyId) - local dStartIntersParam = EgtCurveParamAtPoint( nCopyId, ptInters) - EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam) + local dStartIntersParam = EgtCurveParamAtPoint( nOutlineId, ptInters) + local _, dParE = EgtCurveDomain( nOutlineId) + if abs( dStartIntersParam - dParE) < GEO.EPS_SMALL then + -- se intersezione nel punto finale della curva la ignoro, la ritroverò analizzando l'outline successivo + else + nInters = 1 + local nCopyId = EgtCopy( nOutlineId, nArea2OutlineLayerId) + EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) + EgtRemoveInfo( nCopyId, WIN_CHILD) + AddInfo( nOutlineId, WIN_CHILD, nCopyId) + EgtTrimCurveStartAtParam( nCopyId, dStartIntersParam) + end elseif nInters == 1 then -- trovato secondo punto di intersezione - fine area 2 nInters = 2 @@ -423,6 +528,11 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) EgtSetName( nSplitCopyId, WIN_LEFT) end -- inizio area 1 + local _, dEnd = EgtCurveDomain( nOutlineId) + if abs( dEndIntersParam - dEnd) < GEO.EPS_SMALL then + -- l'intersezione è sul punto finale della curva di outline, quindi è la curva successiva che dà inizio all'area 1 + nOutlineId = EgtGetNext( nOutlineId) or EgtGetFirstInGroup( nOutlineLayerId) + end nCopyId = EgtCopy( nOutlineId, nArea1OutlineLayerId) EgtSetInfo( nCopyId, WIN_SOU, nOutlineId) EgtRemoveInfo( nCopyId, WIN_CHILD) @@ -495,10 +605,12 @@ function WinCreate.CreateAreaFromSplit( nAreaLayerId, nSplitId) nFirstInAreaId = EgtGetFirstInGroup( nArea2OutlineLayerId) sFirstInAreaName = EgtGetName( nFirstInAreaId) end - -- error('qqq') return nArea1Id, nArea2Id end +---------------------------------------------------------------------------------- +---------------------------------- BOTTOMRAIL ------------------------------------ +---------------------------------------------------------------------------------- -- funzione che aggiunge uno zoccolo function WinCreate.AddBottomRail( nAreaId) local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') @@ -510,8 +622,11 @@ function WinCreate.AddBottomRail( nAreaId) end end +---------------------------------------------------------------------------------- +---------------------------------- FERRAMENTA ------------------------------------ +---------------------------------------------------------------------------------- function WinCreate.AddHardware( nFrameId, sFavourite) - EgtSetInfo( nFrameId, WIN_HDW_FAVOURITE, sFavourite ) + EgtSetInfo( nFrameId, WIN_HDW_FAVOURITE, sFavourite) end --------------------------------------------------------------------- diff --git a/Profiles/WinLib/WinManageProject.lua b/Profiles/WinLib/WinManageProject.lua index ab4c0b2..208c809 100644 --- a/Profiles/WinLib/WinManageProject.lua +++ b/Profiles/WinLib/WinManageProject.lua @@ -160,11 +160,15 @@ local function ConvertTableToGeometry( AreaTable, nAreaId) ConvertCurveTableToEntity( nDrawFrameLayerId, CurrCurve) end local nFrameBottomId = EgtGetFirstInGroup(nDrawFrameLayerId) + EgtSetName( nFrameBottomId, WIN_BOTTOM) local nFrameRightId = EgtGetNext(nFrameBottomId) + EgtSetName( nFrameRightId, WIN_RIGHT) local nFrameTopId = EgtGetNext(nFrameRightId) + EgtSetName( nFrameTopId, WIN_TOP) local nFrameLeftId = EgtGetNext(nFrameTopId) + EgtSetName( nFrameLeftId, WIN_LEFT) -- creo frame - nAreaId = WinCreate.CreateGenFrame( nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId, AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL]) + nAreaId = WinCreate.CreateGenFrame( {nFrameBottomId, nFrameRightId, nFrameTopId, nFrameLeftId}, AreaTable[JWD_JOINT][JWD_JOINT_BL], AreaTable[JWD_JOINT][JWD_JOINT_BR], AreaTable[JWD_JOINT][JWD_JOINT_TR], AreaTable[JWD_JOINT][JWD_JOINT_TL]) -- elimino contorno frame EgtErase( nDrawFramePartId) -- se BottomRail @@ -185,7 +189,8 @@ local function ConvertTableToGeometry( AreaTable, nAreaId) EgtSetName( nDrawFramePartId, 'DrawFrame') local nDrawFrameLayerId = EgtGroup( nDrawFramePartId) ConvertCurveTableToEntity( nDrawFrameLayerId, AreaTable[JWD_SPLIT][1]) - local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId)) --, nSplitType) + local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId), AreaTable["SplitType"]) + -- local nArea1Id, nArea2Id = WinCreate.AddGenSplit( nAreaId, EgtGetFirstInGroup(nDrawFrameLayerId)) EgtErase(nDrawFramePartId) ConvertTableToGeometry( AreaTable[JWD_AREA .. 1], nArea1Id) ConvertTableToGeometry( AreaTable[JWD_AREA .. 2], nArea2Id) diff --git a/Profiles/WinProject.lua b/Profiles/WinProject.lua index f8d1cea..296cadf 100644 --- a/Profiles/WinProject.lua +++ b/Profiles/WinProject.lua @@ -43,7 +43,7 @@ end _G.WinCreate_ImportProfile = WinCreate_ImportProfile local function WinCreate_CreateFrame() - WDG.AREAID = WinCreate.CreateFrame(WDG.WIDTH, WDG.HEIGHT, WDG.JOINTBL, WDG.JOINTBR, WDG.JOINTTR, WDG.JOINTTL) + WDG.AREAID = WinCreate.CreateFrame(WDG.FRAMETYPE, WDG.JOINTBL, WDG.JOINTBR, WDG.JOINTTR, WDG.JOINTTL, WDG.WIDTH, WDG.HEIGHT, WDG.HEIGHT2) end _G.WinCreate_CreateFrame = WinCreate_CreateFrame