diff --git a/Designing/WinConst.lua b/Designing/WinConst.lua index 55aa15b..781d3ce 100644 --- a/Designing/WinConst.lua +++ b/Designing/WinConst.lua @@ -363,6 +363,12 @@ WIN_LOGS = 'Log' WIN_PRJ_ORIGSPLIT = 'OrigSplit' +WIN_GASKET = 'Gasket' +WIN_GASKET_LEN = 'GasketLen' +WIN_WATERDRIP = 'Waterdrip' +WIN_WATERDRIP_LEN = 'WaterdripLen' +WIN_TRIM = 'Trim' + WIN_HARDWARE = 'Hardware' WIN_HDW_FAVOURITE = 'HdwFavourite' WIN_HDW_HANDLE = 'HdwHandle' diff --git a/Designing/WinLib/WinCalculate.lua b/Designing/WinLib/WinCalculate.lua index 0c3c4e7..47685d7 100644 --- a/Designing/WinLib/WinCalculate.lua +++ b/Designing/WinLib/WinCalculate.lua @@ -4549,8 +4549,10 @@ function WinCalculate.AddHardwareForSash( nFrameId, bOnlyRequest) fhOutput:close() -- disegno la ferramenta - for i = 1, #SashList do - DrawSashHardware( SashList[i].nAreaId, nFrameId) + if s_bCalcSolid then + for i = 1, #SashList do + DrawSashHardware( SashList[i].nAreaId, nFrameId) + end end end @@ -4578,5 +4580,319 @@ function WinCalculate.AddHardware( nAreaId) end end + +---------------------------------------------------------------------------------- +----------------------------------- ACCESSORI ---------------------------------- +---------------------------------------------------------------------------------- +-- funzione che calcola e disegna il gocciolatoio +local function CalcWaterdrip( nPartId, nOutlineId, nAreaId, bDraw) + + -- verifico presenza gocciolatoio + local nProfileLayId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) + local nProfileId = EgtGetFirstNameInGroup( nProfileLayId, WIN_PRF_MAIN) + local nWaterdripId = EgtGetFirstNameInGroup( nProfileId, WIN_ALU) + if not nWaterdripId then + return + end + + -- gruppi per i conti + local nGrp = EgtGroup( nPartId) + local nSolidLayId = EgtGetFirstNameInGroup( nPartId, WIN_SOLID) + + -- recupero punto di incontro con pezzo precedente + local nPrevId = EgtGetInfo( nOutlineId, WIN_PREV_OUTLINES, 'i') + local nPrevPart = EgtGetInfo( nPrevId, WIN_REF_PART, 'i') + local nPrevGeo = EgtGetFirstNameInGroup( nPrevPart, WIN_GEO) + local nPrevCrv = EgtGetFirstNameInGroup( nPrevGeo, WIN_IN) + local nPrevCopy = EgtCopyGlob( nPrevCrv, nGrp) + EgtExtendCurveStartByLen( nPrevCopy, 200) + local ptPrev = EgtIP( nOutlineId, nPrevCopy, ORIG()) + -- recupero punto di incontro con pezzo successivo + local nNextId = EgtGetInfo( nOutlineId, WIN_NEXT_OUTLINES, 'i') + local nNextPart = EgtGetInfo( nNextId, WIN_REF_PART, 'i') + local nNextGeo = EgtGetFirstNameInGroup( nNextPart, WIN_GEO) + local nNextCrv = EgtGetFirstNameInGroup( nNextGeo, WIN_IN) + local nNextCopy = EgtCopyGlob( nNextCrv, nGrp) + EgtExtendCurveEndByLen( nNextCopy, 200) + local ptNext = EgtIP( nOutlineId, nNextCopy, ORIG()) + -- salvo i parametri nei punti di intersezione + local dParPrev = EgtCurveParamAtPoint( nOutlineId, ptPrev, 100 * GEO.EPS_SMALL) + local dParNext = EgtCurveParamAtPoint( nOutlineId, ptNext, 100 * GEO.EPS_SMALL) + local vParams = { dParPrev, dParNext} + + -- verifico se outline va spezzato ulteriormente a causa di montanti + local nBottomRail = EgtGetInfo( nOutlineId, WIN_REF_BOTTOMRAIL_PART, 'i') + if not nBottomRail then -- se ha bottomrail gli split non causano interruzioni nel gocciolatoio + local vStack = {nAreaId} + local i = 1 + while vStack[i] do + local nAreaType = EgtGetInfo( vStack[i], WIN_AREATYPE, 'i') + if nAreaType == WIN_AREATYPES.FRAME or nAreaType == WIN_AREATYPES.SPLIT then + local nSplitId = EgtGetFirstNameInGroup( vStack[i], WIN_SPLIT) + if nSplitId then + local nSplitType = EgtGetInfo( nSplitId, WIN_SPLITTYPE, 'i') + if nSplitType ~= WIN_SPLITTYPES.FRENCH then + -- recupero il pezzo associato allo split + local nSplitOutline = EgtGetFirstInGroup( nSplitId) + local nSplitPart = EgtGetInfo( nSplitOutline, WIN_REF_PART, 'i') + -- recupero le intersezioni con la curva di outline + local nSplitGeo = EgtGetFirstNameInGroup( nSplitPart, WIN_GEO) + local nCrv1 = EgtGetFirstNameInGroup( nSplitGeo, WIN_IN) + local nCopy1 = EgtCopyGlob( nCrv1, nGrp) + EgtExtendCurveStartByLen( nCopy1, 200) + EgtExtendCurveEndByLen( nCopy1, 200) + local pt1 = EgtIP( nOutlineId, nCopy1, ORIG()) + local nCrv2 = EgtGetFirstNameInGroup( nSplitGeo, WIN_OUT) + local nCopy2 = EgtCopyGlob( nCrv2, nGrp) + EgtExtendCurveStartByLen( nCopy2, 200) + EgtExtendCurveEndByLen( nCopy2, 200) + local pt2 = EgtIP( nOutlineId, nCopy2, ORIG()) + -- salvo i parametri di intersezione + local dPar1 = EgtCurveParamAtPoint( nOutlineId, pt1, 100 * GEO.EPS_SMALL) + local dPar2 = EgtCurveParamAtPoint( nOutlineId, pt2, 100 * GEO.EPS_SMALL) + table.insert( vParams, dPar1) + table.insert( vParams, dPar2) + + -- salvo le sue sottoaree per analizzarle + local vChildren = EgtGetNameInGroup( vStack[i], WIN_AREA .. '*') or {} + vStack = EgtJoinTables( vStack, vChildren) + end + end + end + i = i + 1 + end + end + + -- riordino i parametri ( non dovrebbero mai capitare parametri coincidenti) + table.sort( vParams) + + local dLenTot = 0 + for i = 1, #vParams, 2 do + -- creo la guida di estrusione per il gocciolatoio + local nGuideId = EgtCopyGlob( nOutlineId, nGrp) + -- trim della curva + EgtTrimCurveStartEndAtParam( nGuideId, vParams[i], vParams[i+1]) + -- aggiorno la lunghezza + dLenTot = dLenTot + EgtCurveLength( nGuideId) + -- disegno + if bDraw and s_bCalcSolid then + -- estrudo la superficie + local nStm = CreateProfileSurf( nGuideId, nProfileId, WIN_ALU, 0, nSolidLayId) + EgtSetColor( nStm, Color3d( 128, 128, 128)) + EgtSetName( nStm, WIN_WATERDRIP) + end + end + + -- salvo la lunghezza del gocciolatoio + local nAreaGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_AREA .. '*') + EgtSetInfo( nAreaGrp, WIN_WATERDRIP_LEN, dLenTot) + + EgtErase( nGrp) + +end + +--------------------------------------------------------------------- +-- funzione che calcola e disegna le guarnizioni +local function CalcGaskets( nAreaId, bDraw) + + local nOutlineLayId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE) + local vOrigOutlines = EgtGetAllInGroup( nOutlineLayId) + local dLenTot = 0 + + -- recupero dati dei pezzi che serviranno nei conti e i veri outlines da considerare + local tParts = {} + local vOutlines = {} + for i = 1, #vOrigOutlines do + local nPartId = FindAssociatedPart( vOrigOutlines[i]) + local nProfileLayId = EgtGetFirstNameInGroup( nPartId, WIN_PROFILE) + local nMainProfileId = EgtGetFirstNameInGroup( nProfileLayId, WIN_PRF_MAIN) + local nFrameId = EgtGetFirstNameInGroup( nMainProfileId, WIN_SECTIONFRAME) + local frProfile = EgtFR( nFrameId, GDB_ID.ROOT) + tParts[i] = { nId = nPartId, nProfileId = nMainProfileId, frProfile = frProfile} + vOutlines[i] = EgtGetInfo( nPartId, WIN_REF_OUTLINE, 'i') + end + + -- gruppo temporaneo per i conti + local nGrp = EgtGroup( nAreaId) + + -- cerco tutte le possibili guarnizioni + for i = 1, 3 do + -- nome della guarnizione corrente + local sGasket = WIN_GASKET .. tostring( i) + local vCrvs = {} + for i = 1, #vOutlines do + local nCrv = EgtCopyGlob( vOutlines[i], nGrp) + table.insert( vCrvs, nCrv) + + -- calcolo offset da applicare alla curva + local dOffs + local vGasketIds = EgtGetNameInGroup( tParts[i].nProfileId, sGasket .. '*') + if #vGasketIds == 1 then + -- se guarnizione recupero offset dalla sua dimensione + local b3Box = EgtGetBBoxRef( vGasketIds[1], GDB_BB.STANDARD, tParts[i].frProfile) + dOffs = b3Box:getMax():getX() + tParts[i].sGasket = sGasket + elseif #vGasketIds > 1 then + -- se ho più guarnizioni devo identificare quella dal lato corretto ( caso di split) + local nCrvRef = EgtIf( i == 1, vOrigOutlines[2], vOrigOutlines[i-1]) + local _, _, nSide = EgtPointCurveDistSide( EgtMP( nCrvRef), nCrv, Z_AX()) + if nSide == 1 then + tParts[i].sGasket = sGasket .. '_1' + local nGasketId = EgtGetFirstNameInGroup( tParts[i].nProfileId, tParts[i].sGasket) + local b3Box = EgtGetBBoxRef( nGasketId, GDB_BB.STANDARD, tParts[i].frProfile) + dOffs = b3Box:getMin():getX() + else + tParts[i].sGasket = sGasket .. '_2' + local nGasketId = EgtGetFirstNameInGroup( tParts[i].nProfileId, tParts[i].sGasket) + local b3Box = EgtGetBBoxRef( nGasketId, GDB_BB.STANDARD, tParts[i].frProfile) + dOffs = b3Box:getMax():getX() + end + else + -- se non ha guarnizione è curva di trim ( quindi deve avere info) + dOffs = EgtGetInfo( tParts[i].nProfileId, WIN_TRIM .. sGasket, 'd') + if not dOffs then + -- se non ha info di trim significa che devo passare alla guarnizione successiva + vCrvs = {} + break + end + dOffs = - dOffs + tParts[i].sGasket = nil + end + + -- offset + EgtOffsetCurve( nCrv, dOffs) + end + + if #vCrvs > 0 then + -- taglio le curve + TrimAndOrientOrderedCurves( vCrvs, true) + + -- aggiorno lunghezza + for i = 1, #vCrvs do + if tParts[i].sGasket then -- devo ignorare le curve di trim + dLenTot = dLenTot + EgtCurveLength( vCrvs[i]) + end + end + + -- disegno + if bDraw and s_bCalcSolid then + for i = 1, #vCrvs do + if tParts[i].sGasket then + -- estrusione principale della giunzione + local nSolidLayerId = EgtGetFirstNameInGroup( tParts[i].nId, WIN_SOLID) + local nGasketStm = CreateProfileSurf( vOutlines[i], tParts[i].nProfileId, tParts[i].sGasket, 100, nSolidLayerId) + EgtSetColor( nGasketStm, Color3d( 128, 128, 128)) + EgtSetName( nGasketStm, sGasket) + + -- trim start + local nPrev = EgtIf( i == 1, #vCrvs, i - 1) + local nGuideId + if not tParts[nPrev].sGasket then + -- se precedente è curva di trim la uso direttamente + nGuideId = EgtCopyGlob( vCrvs[nPrev], nSolidLayerId) + EgtInvertCurve( nGuideId) + else + -- taglio lungo la bisettrice + local vtDir = 0.5 * ( EgtSV( vCrvs[i]) - EgtEV( vCrvs[nPrev])) + if vtDir:isSmall() then + vtDir = EgtSV( vCrvs[i]) + vtDir:rotate( Z_AX(), 90) + end + nGuideId = EgtLinePVL( nSolidLayerId, EgtSP( vCrvs[i]), vtDir, 200) + EgtExtendCurveStartByLen( nGuideId, 100) + end + local nTrimStart = EgtSurfTmByExtrusion( nSolidLayerId, nGuideId, - 200 * Z_AX()) + EgtSurfTmIntersect( nGasketStm, nTrimStart) + EgtErase( { nGuideId, nTrimStart}) + + -- trim end + local nNext = EgtIf( i == #vCrvs, 1, i + 1) + if not tParts[nNext].sGasket then + nGuideId = EgtCopyGlob( vCrvs[nNext], nSolidLayerId) + else + local vtDir = 0.5 * ( EgtSV( vCrvs[nNext]) - EgtEV( vCrvs[i])) + if vtDir:isSmall() then + vtDir = EgtSV( vCrvs[nNext]) + vtDir:rotate( Z_AX(), 90) + end + nGuideId = EgtLinePVL( nSolidLayerId, EgtEP( vCrvs[i]), vtDir, 200) + EgtExtendCurveStartByLen( nGuideId, 100) + end + local nTrimEnd = EgtSurfTmByExtrusion( nSolidLayerId, nGuideId, - 200 * Z_AX()) + EgtInvertSurf( nTrimEnd) + EgtSurfTmIntersect( nGasketStm, nTrimEnd) + EgtErase( { nGuideId, nTrimEnd}) + end + end + end + end + end + + -- aggiorno valore lunghezza + local nAreaGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, WIN_AREA .. '*') + local dLenOld = EgtGetInfo( nAreaGrp, WIN_GASKET_LEN, 'd') or 0 + EgtSetInfo( nAreaGrp, WIN_GASKET_LEN, dLenOld + dLenTot) + + EgtErase( nGrp) +end + +--------------------------------------------------------------------- +function WinCalculate.AddAccessories( nAreaId, bDraw) + + local nAreaType = EgtGetInfo( nAreaId, WIN_AREATYPE, 'i') + if nAreaType == WIN_AREATYPES.FRAME then + -- gocciolatoio + local nOutlineLayId = EgtGetFirstNameInGroup( nAreaId, WIN_OUTLINE) + local nBottomId = EgtGetFirstNameInGroup( nOutlineLayId, WIN_BOTTOM) + local nPartId = EgtGetInfo( nBottomId, WIN_REF_PART, 'i') + CalcWaterdrip( nPartId, nBottomId, nAreaId, bDraw) + + -- guarnizioni se definisce un french split + local nSplitId = EgtGetFirstNameInGroup( nAreaId, WIN_SPLIT) or GDB_ID.NULL + local nSplitType = EgtGetInfo( nSplitId, WIN_SPLITTYPE, 'i') + if nSplitType == WIN_SPLITTYPES.FRENCH then + CalcGaskets( nAreaId, bDraw) + end + -- TODO guarnizioni per gocciolatoio + + elseif nAreaType == WIN_AREATYPES.SASH then + -- guarnizioni anta + CalcGaskets( nAreaId, bDraw) + + elseif nAreaType == WIN_AREATYPES.SPLIT then + -- guarnizioni se è french split che non deriva da un french split + local nSplitId = EgtGetFirstNameInGroup( nAreaId, WIN_SPLIT) + local nSplitType = EgtGetInfo( nSplitId, WIN_SPLITTYPE, 'i') + if nSplitType == WIN_SPLITTYPES.FRENCH then + local nParentArea = EgtGetParent( nAreaId) + local nParentSplit = EgtGetFirstNameInGroup( nParentArea, WIN_SPLIT) or GDB_ID.NULL + local nSplitType = EgtGetInfo( nParentSplit, WIN_SPLITTYPE, 'i') + if nSplitType ~= WIN_SPLITTYPES.FRENCH then + CalcGaskets( nAreaId, bDraw) + end + end + + elseif nAreaType == WIN_AREATYPES.NULL then + -- guarnizioni se non deriva da french split e ha come sottoarea un'anta + local nParentArea = EgtGetParent( nAreaId) + local nParentSplit = EgtGetFirstNameInGroup( nParentArea, WIN_SPLIT) or GDB_ID.NULL + local nSplitType = EgtGetInfo( nParentSplit, WIN_SPLITTYPE, 'i') + if nSplitType == WIN_SPLITTYPES.MULLION then + local nChildArea = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*') or GDB_ID.NULL + local nChildType = EgtGetInfo( nChildArea, WIN_AREATYPE, 'i') + if nChildType == WIN_AREATYPES.SASH then + CalcGaskets( nAreaId, bDraw) + end + end + end + + -- calcolo accessori per sotto-aree + local nChildAreaId = EgtGetFirstNameInGroup( nAreaId, WIN_AREA .. '*') + while nChildAreaId do + WinCalculate.AddAccessories( nChildAreaId, bDraw) + nChildAreaId = EgtGetNextName( nChildAreaId, WIN_AREA .. '*') + end +end + --------------------------------------------------------------------- return WinCalculate diff --git a/Designing/WinProject.lua b/Designing/WinProject.lua index 92ef167..30c90e4 100644 --- a/Designing/WinProject.lua +++ b/Designing/WinProject.lua @@ -150,4 +150,8 @@ local function WinCreate_GetHardwareOptionPath() end _G.WinCreate_GetHardwareOptionPath = WinCreate_GetHardwareOptionPath ---------------------------------------------------------------------- +---------------------------------------------------------------------------------- +local function WinCalculate_AddAccessories() + WinCalculate.AddAccessories( WDG.FRAMEID, WDG.DRAW) +end +_G.WinCalculate_AddAccessories = WinCalculate_AddAccessories