diff --git a/LuaLibs/BeamExec.lua b/LuaLibs/BeamExec.lua index a5d8226..9f1de4f 100644 --- a/LuaLibs/BeamExec.lua +++ b/LuaLibs/BeamExec.lua @@ -375,13 +375,13 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS) local dDeltaE = BeamData.OVM_MID for i = 1, #PARTS do -- dati del pezzo - local b3Part = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.EXACT) - if b3Part:isEmpty() or PARTS[i].b3Box:isEmpty() then break end - EgtOutLog( 'PartSez=' .. EgtNumToString( b3Part:getDimY(), 1) .. 'x' .. EgtNumToString( b3Part:getDimZ(), 1), 3) + local b3BoxExact = EgtGetBBoxGlob( PARTS[i].id or GDB_ID.NULL, GDB_BB.EXACT) + if b3BoxExact:isEmpty() or PARTS[i].b3Part:isEmpty() then break end + EgtOutLog( 'PartSez=' .. EgtNumToString( b3BoxExact:getDimY(), 1) .. 'x' .. EgtNumToString( b3BoxExact:getDimZ(), 1), 3) -- se sezione compatibile e lunghezza disponibile sufficiente - local dPartLen = PARTS[i].b3Box:getDimX() - local dPartWidth = PARTS[i].b3Box:getDimY() - local dPartHeight = PARTS[i].b3Box:getDimZ() + local dPartLen = PARTS[i].b3Part:getDimX() + local dPartWidth = PARTS[i].b3Part:getDimY() + local dPartHeight = PARTS[i].b3Part:getDimZ() local dNextLen = dLen - EgtIf( i == 1, dDeltaS, 0) - dPartLen - dDeltaE if (( abs( dPartWidth - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartHeight - dRawH) < 100 * GEO.EPS_SMALL) or ( abs( dPartHeight - dRawW) < 100 * GEO.EPS_SMALL and abs( dPartWidth - dRawH) < 100 * GEO.EPS_SMALL)) and @@ -411,7 +411,7 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS) return false, sOut end -- aggiungo faccia per taglio iniziale al pezzo - BeamLib.AddPartStartFace( PARTS[i].id, PARTS[i].b3Box) + BeamLib.AddPartStartFace( PARTS[i].id, PARTS[i].b3Part) -- se sovramateriale di testa, lo notifico if dDeltaS > 0.09 then EgtSetInfo( PARTS[i].idRaw, 'HOVM', dDeltaS) @@ -423,16 +423,16 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS) EgtSetInfo( PARTS[i].idRaw, 'TOVM', dDeltaE) end -- aggiungo faccia per taglio finale al pezzo - BeamLib.AddPartEndFace( PARTS[i].id, PARTS[i].b3Box) + BeamLib.AddPartEndFace( PARTS[i].id, PARTS[i].b3Part) -- inserisco il pezzo nel grezzo EgtDeselectPartObjs( PARTS[i].id) - local ptPos = b3Part:getMin() - PARTS[i].b3Box:getMin() + Vector3d( dDelta, ( dRawW - dPartWidth) / 2, ( dRawH - dPartHeight) / 2) + local ptPos = b3BoxExact:getMin() - PARTS[i].b3Part:getMin() + Vector3d( dDelta, ( dRawW - dPartWidth) / 2, ( dRawH - dPartHeight) / 2) EgtAddPartToRawPart( PARTS[i].id, ptPos, PARTS[i].idRaw) if abs( dPartWidth - dRawW) > 100 * GEO.EPS_SMALL then -- rotazione attorno a centro geometria complessiva del pezzo EgtRotatePartInRawPart( PARTS[i].id, X_AX(), 90) -- correggo per eccentricità solido rispetto a geometria complessiva del pezzo - local vtEccOri = PARTS[i].b3Box:getCenter() - b3Part:getCenter() + local vtEccOri = PARTS[i].b3Part:getCenter() - b3BoxExact:getCenter() local vtEccRot = Vector3d( vtEccOri) vtEccRot:rotate( X_AX(), 90) EgtMovePartInRawPart( PARTS[i].id, ( vtEccOri - vtEccRot)) @@ -450,9 +450,9 @@ function BeamExec.ProcessBeams( dRawW, dRawH, dRawL, dOvmHead, dOvmMid, PARTS) PARTS[i].dWidth = PARTS[i].b3Raw:getDimY() PARTS[i].dHeight = PARTS[i].b3Raw:getDimZ() PARTS[i].bSquareSection = abs( PARTS[i].dWidth - PARTS[i].dHeight) < 100 * GEO.EPS_SMALL - PARTS[i].b3Solid = EgtGetBBoxGlob( EgtGetFirstNameInGroup( PARTS[i].id, 'Box') or GDB_ID.NULL, GDB_BB.STANDARD) PARTS[i].nIndexInParts = i PARTS[i].CombinationList = GetAvailableCombinations( PARTS[i]) + PARTS[i].SplittingPoints = BeamLib.GetPartSplittingPoints( PARTS[i]) else local sOut = 'Error: part L(' .. EgtNumToString( dPartLen, 1) .. ') too big for raw part L(' .. EgtNumToString( dLen - 0.1, 1) .. ')' return false, sOut @@ -984,6 +984,79 @@ local function CalculateMachinings( vProc, Part) return MACHININGS end +------------------------------------------------------------------------------------------------------------- +local function PrepareMachiningsForSorting( ) + local nFeatureInternalIndex = 1 + for i = 1, #MACHININGS do + local MachiningCurrent = MACHININGS[i].Machining + local ProcIdCurrent = MACHININGS[i].Proc.id + + -- conversione campo sStage in nStage, numerico e ordinabile + if not MachiningCurrent.sStage then + MachiningCurrent.sStage = '' + end + if MachiningCurrent.sStage == 'Head' then + MachiningCurrent.nStage = 1 + elseif MachiningCurrent.sStage == 'Tail' then + MachiningCurrent.nStage = 3 + elseif MachiningCurrent.sStage == 'AfterTail' then + MachiningCurrent.nStage = 4 + else + MachiningCurrent.nStage = 2 + end + + if i > 1 then + local MachiningPrevious = MACHININGS[i - 1].Machining + local ProcIdPrevious = MACHININGS[i - 1].Proc.id + if ProcIdCurrent == ProcIdPrevious then + -- nStage devono essere sempre crescenti nella stessa feature + if MachiningCurrent.nStage < MachiningPrevious.nStage then + MachiningCurrent.nStage = MachiningPrevious.nStage + end + -- assegnazione indice interno alla feature + nFeatureInternalIndex = nFeatureInternalIndex + 1 + else + nFeatureInternalIndex = 1 + end + end + MachiningCurrent.nFeatureInternalIndex = nFeatureInternalIndex + + -- se fase di lavoro standard, assegnazione dello spezzone + if MachiningCurrent.nStage == 2 then + + end + end +end + +------------------------------------------------------------------------------------------------------------- +local function SortMachiningsBySegment( MachiningA, MachiningB) + if MachiningA.Machining.nSegment > MachiningB.Machining.nSegment then + return false + elseif MachiningB.Machining.nSegment > MachiningA.Machining.nSegment then + return true + end + + local toolFamilyA = TOOLS[ MachiningA.Machining.nToolIndex].sFamily + local toolFamilyB = TOOLS[ MachiningB.Machining.nToolIndex].sFamily + local toolFamilyOrder = { + SAWBLADE = 1, + DRILLBIT = 2, + MILL = 3, + MORTISE = 4 + } + if toolFamilyOrder[toolFamilyA.Tool] ~= toolFamilyOrder[toolFamilyB.Tool] then + return toolFamilyOrder[toolFamilyA.Tool] < toolFamilyOrder[toolFamilyB.Tool] + end + + if MachiningA.Machining.sEdgeType == 'Side' and MachiningB.Machining.sEdgeType ~= 'Side' then + return true + elseif MachiningB.Machining.sEdgeType == 'Side' and MachiningA.Machining.sEdgeType ~= 'Side' then + return false + end + + return false +end + ------------------------------------------------------------------------------------------------------------- local function PrintFeatures( vProc, Part) if vProc then @@ -1328,7 +1401,7 @@ function BeamExec.ProcessMachinings( PROCESSINGS, PARTS) MACHININGS = CalculateMachinings( vProc, PARTS[nPart]) -- TODO riordinare lavorazioni ottimizzando cambio utensile/spezzone ecc..., mantenendo dipendenze definite prima - -- ordino le lavorazioni + --table.sort( MACHININGS, SortMachinings) -- MACHININGS = OrderMachining( MACHININGS, PARTS[nPart]) -- aggiungo la fase, se non è la prima diff --git a/LuaLibs/BeamLib.lua b/LuaLibs/BeamLib.lua index c63c3e3..a82273e 100644 --- a/LuaLibs/BeamLib.lua +++ b/LuaLibs/BeamLib.lua @@ -90,6 +90,48 @@ function BeamLib.AddPartEndFace( PartId, b3Solid) return true end +------------------------------------------------------------------------------------------------------------- +function BeamLib.GetPartSplittingPoints( Part, OptionalParameters) + local PartSplittingPoints = {} + local dPartLength = Part.b3Part:getDimX() + + -- parametri opzionali + if not OptionalParameters then + OptionalParameters = {} + end + local dMaxSegmentLength = OptionalParameters.dMaxSegmentLength or BeamData.LONGCUT_MAXLEN + local dMaxSegmentLengthOnEdges = OptionalParameters.dMaxSegmentLengthOnEdges or BeamData.LONGCUT_ENDLEN + + if dPartLength < dMaxSegmentLength + 10 * GEO.EPS_SMALL then + return {} + elseif dPartLength >= dMaxSegmentLength + 10 * GEO.EPS_SMALL + and dPartLength < 3 * dMaxSegmentLengthOnEdges + 10 * GEO.EPS_SMALL then + local dXPartCentralPoint = ( Part.b3Part:getMax():getX() - Part.b3Part:getMin():getX()) / 2 + table.insert( PartSplittingPoints, Point3d( dXPartCentralPoint, 0, 0)) + else + -- punto estremo destro + local dSplitXRight = Part.b3Part:getMax():getX() - dMaxSegmentLengthOnEdges + table.insert( PartSplittingPoints, Point3d( dSplitXRight, 0, 0)) + + -- punti centrali + local dPartCentralLength = dPartLength - 2 * dMaxSegmentLengthOnEdges + local nSplitParts = max( ceil( dPartCentralLength / dMaxSegmentLength + 10 * GEO.EPS_SMALL), 1) + local dSplitPartsLen = dPartCentralLength / nSplitParts + for i = 1, ( nSplitParts - 1) do + local ptOn + local dCurrentPointX = dSplitXRight - i * dSplitPartsLen + ptOn = Point3d( dCurrentPointX, 0, 0) + table.insert( PartSplittingPoints, ptOn) + end + + -- punto estremo sinistro + local dSplitXLeft = Part.b3Part:getMin():getX() + dMaxSegmentLengthOnEdges + table.insert( PartSplittingPoints, Point3d( dSplitXLeft, 0, 0)) + end + + return PartSplittingPoints +end + ------------------------------------------------------------------------------------------------------------- function BeamLib.AddPhaseWithRawParts( nRawId, OriXR, PosXR, dDeltaSucc) EgtAddPhase() @@ -193,22 +235,22 @@ end function BeamLib.GetAffectedFaces( Proc, Part) local vtFacesAffected = { bTop = false, bBottom = false, bFront = false, bBack = false, bLeft = false, bRight = false} if Proc.b3Box and not Proc.b3Box:isEmpty() then - if Proc.b3Box:getMax():getZ() > Part.b3Solid:getMax():getZ() - 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMax():getZ() > Part.b3Part:getMax():getZ() - 500 * GEO.EPS_SMALL then vtFacesAffected.bTop = true end - if Proc.b3Box:getMin():getZ() < Part.b3Solid:getMin():getZ() + 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMin():getZ() < Part.b3Part:getMin():getZ() + 500 * GEO.EPS_SMALL then vtFacesAffected.bBottom = true end - if Proc.b3Box:getMin():getY() < Part.b3Solid:getMin():getY() + 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMin():getY() < Part.b3Part:getMin():getY() + 500 * GEO.EPS_SMALL then vtFacesAffected.bFront = true end - if Proc.b3Box:getMax():getY() > Part.b3Solid:getMax():getY() - 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMax():getY() > Part.b3Part:getMax():getY() - 500 * GEO.EPS_SMALL then vtFacesAffected.bBack = true end - if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMin():getX() < Part.b3Part:getMin():getX() + 500 * GEO.EPS_SMALL then vtFacesAffected.bLeft = true end - if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - 500 * GEO.EPS_SMALL then + if Proc.b3Box:getMax():getX() > Part.b3Part:getMax():getX() - 500 * GEO.EPS_SMALL then vtFacesAffected.bRight = true end end diff --git a/LuaLibs/DiceCut.lua b/LuaLibs/DiceCut.lua index 36a9922..0b5a02d 100644 --- a/LuaLibs/DiceCut.lua +++ b/LuaLibs/DiceCut.lua @@ -403,7 +403,7 @@ function DiceCut.GetDice( Part, Face1, Face2, OptionalParameters) -- recupero gruppo per geometria addizionale local nAddGrpId = BeamLib.GetAddGroup( Part.id) -- se il box non è passato tra i parametri opzionali, faccio i calcoli sul SOLID del Part - local b3BoxToDicing = OptionalParameters.b3BoxToDicing or Part.b3Solid + local b3BoxToDicing = OptionalParameters.b3BoxToDicing or Part.b3Part -- copio dati passati su variabili locali local ptCMainFace, vtNMainFace, ptCSubordinateFace, vtNSubordinateFace, bGetOrtoPlanes if Face1.ptCenter and Face1.vtNormal then diff --git a/LuaLibs/FaceData.lua b/LuaLibs/FaceData.lua index e5a2700..bf5f5eb 100644 --- a/LuaLibs/FaceData.lua +++ b/LuaLibs/FaceData.lua @@ -120,7 +120,7 @@ function FaceData.GetFacesInfo( Proc, Part) -- frame OCS faccia Faces[i].vtFrameHV = Frame3d( Faces[i].ptCenter, Faces[i].vtN) -- elevazione calcolata rispetto al box della parte - Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.id, i - 1, Part.b3Solid, true, GDB_ID.ROOT) + Faces[i].dElevation = EgtSurfTmFacetElevationInBBox( Proc.id, i - 1, Part.b3Part, true, GDB_ID.ROOT) -- TODO qui sarebbe meglio l'area vera e non quella del rettangolo minimo local _, dLongEdgeDimension, dShortEdgeDimension = EgtSurfTmFacetMinAreaRectangle( Proc.id, i - 1, GDB_ID.ROOT) Faces[i].dArea = dShortEdgeDimension * dLongEdgeDimension @@ -180,7 +180,7 @@ local function GetTunnelFaces( Proc, Part) end -- faccia centrale - local nMiddleTmId = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, Part.b3Solid, GDB_ID.ROOT) + local nMiddleTmId = EgtSurfTmPlaneInBBox( nAddGrpId, ptTunnelCenter, vtTunnelDirection, Part.b3Part, GDB_ID.ROOT) -- TODO se non si riesce a costruire la faccia bisogna dare errore o semplicemente non ritornarla?? for i = 1, Proc.nFct do EgtCutSurfTmPlane( nMiddleTmId, Proc.Faces[i].ptCenter, -Proc.Faces[i].vtN, false, GDB_ID.ROOT) diff --git a/LuaLibs/FeatureLib.lua b/LuaLibs/FeatureLib.lua index e2a5db1..24115c2 100644 --- a/LuaLibs/FeatureLib.lua +++ b/LuaLibs/FeatureLib.lua @@ -98,14 +98,12 @@ end --------------------------------------------------------------------- -- restituisce true se almeno una delle dimensioni della feature è maggiore o uguale ad una delle dimensioni principali del pezzo (tolleranza 1 mm) -local function IsAnyDimensionLongAsPart( Proc) +local function IsAnyDimensionLongAsPart( Proc, Part) local bResult = false - local nBoxSolidId = EgtGetFirstNameInGroup( Proc.idPart or GDB_ID.NULL, 'Box') - local b3Solid = EgtGetBBoxGlob( nBoxSolidId, GDB_BB.STANDARD) - if Proc.b3Box:getDimX() > b3Solid:getDimX() - 1000 * GEO.EPS_SMALL or - Proc.b3Box:getDimY() > b3Solid:getDimY() - 1000 * GEO.EPS_SMALL or - Proc.b3Box:getDimZ() > b3Solid:getDimZ() - 1000 * GEO.EPS_SMALL then + if Proc.b3Box:getDimX() > Part.b3Part:getDimX() - 1000 * GEO.EPS_SMALL or + Proc.b3Box:getDimY() > Part.b3Part:getDimY() - 1000 * GEO.EPS_SMALL or + Proc.b3Box:getDimZ() > Part.b3Part:getDimZ() - 1000 * GEO.EPS_SMALL then bResult = true end @@ -141,7 +139,7 @@ function FeatureLib.ClassifyTopology( Proc, Part) local bIsFeatureCuttingEntireSection = IsFeatureCuttingEntireSection( Proc.b3Box, Part) local bIsFeatureCuttingEntireLength = IsFeatureCuttingEntireLength( Proc.b3Box, Part) - local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc) + local bIsAnyDimensionLongAsPart = IsAnyDimensionLongAsPart( Proc, Part) local vAdj = Proc.AdjacencyMatrix local bAllAnglesConcave, bAllRightAngles = AreAllAnglesConcaveOrRight( vAdj) local vTriangularFaces = FaceData.GetTriangularFaces( Proc) @@ -305,13 +303,13 @@ function FeatureLib.MachiningNeedsSplitting( dMachiningLengthOnX, Part, Optional local dMaxSegmentLength = OptionalParameters.dMaxSegmentLength or BeamData.LONGCUT_MAXLEN bMachiningNeedsSplitting = ( dMachiningLengthOnX > dMaxSegmentLength + 10 * GEO.EPS_SMALL) - or ( dMachiningLengthOnX > 0.7 * Part.b3Solid:getDimX() + 10 * GEO.EPS_SMALL) + or ( dMachiningLengthOnX > 0.7 * Part.b3Part:getDimX() + 10 * GEO.EPS_SMALL) return bMachiningNeedsSplitting end ------------------------------------------------------------------------------------------------------------- function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) - local vFeatureSplittingPoints = {} + local FeatureSplittingPoints = {} local bFeatureStartsOnEdgeLeft = false local bFeatureStartsOnEdgeRight = false local dSplitXLeft = Proc.b3Box:getMin():getX() @@ -333,10 +331,10 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) end -- verifica se necessari spezzoni differenti sugli estremi - if Proc.b3Box:getMin():getX() < Part.b3Solid:getMin():getX() + dMaxSegmentLengthOnEdges - 10 * GEO.EPS_SMALL then + if Proc.b3Box:getMin():getX() < Part.b3Part:getMin():getX() + dMaxSegmentLengthOnEdges - 10 * GEO.EPS_SMALL then bFeatureStartsOnEdgeLeft = true end - if Proc.b3Box:getMax():getX() > Part.b3Solid:getMax():getX() - dMaxSegmentLengthOnEdges + 10 * GEO.EPS_SMALL then + if Proc.b3Box:getMax():getX() > Part.b3Part:getMax():getX() - dMaxSegmentLengthOnEdges + 10 * GEO.EPS_SMALL then bFeatureStartsOnEdgeRight = true end @@ -345,13 +343,13 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) if bFeatureStartsOnEdgeLeft then -- decido punto spezzatura verso la coda if Proc.b3Box:getDimX() > dMaxSegmentLengthOnEdges * 2 then - dSplitXLeft = max( Part.b3Solid:getMin():getX() + dMaxSegmentLengthOnEdges, Proc.b3Box:getMin():getX() + dMinSegmentLength) + dSplitXLeft = max( Part.b3Part:getMin():getX() + dMaxSegmentLengthOnEdges, Proc.b3Box:getMin():getX() + dMinSegmentLength) else -- se pezzo abbastanza piccolo, spezzo in mezzo al 'pezzo + grezzo restante' - if Part.dRestLength + Part.b3Solid:getDimX() < BeamData.dMinRaw * 1.5 then - dSplitXLeft = Part.b3Solid:getMax():getX() - ( ( Part.dRestLength + Part.b3Solid:getDimX()) / 2) + if Part.dRestLength + Part.b3Part:getDimX() < BeamData.dMinRaw * 1.5 then + dSplitXLeft = Part.b3Part:getMax():getX() - ( ( Part.dRestLength + Part.b3Part:getDimX()) / 2) else - dSplitXLeft = max( Proc.b3Box:getMin():getX() + ( BeamData.dMinRaw)/2 + 150, Part.b3Solid:getMax():getX() - dMaxSegmentLengthOnEdges) + dSplitXLeft = max( Proc.b3Box:getMin():getX() + ( BeamData.dMinRaw)/2 + 150, Part.b3Part:getMax():getX() - dMaxSegmentLengthOnEdges) end end dFeatureCentralLength = abs( dSplitXRight - dSplitXLeft) @@ -361,7 +359,7 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) -- calcolo punto estremo destro local ptSplitXRight if bFeatureStartsOnEdgeRight then - dSplitXRight = min( ( Proc.b3Box:getMax():getX() - dMinSegmentLength), Part.b3Solid:getMax():getX() - dMaxSegmentLengthOnEdges) + dSplitXRight = min( ( Proc.b3Box:getMax():getX() - dMinSegmentLength), Part.b3Part:getMax():getX() - dMaxSegmentLengthOnEdges) if dSplitXRight - dSplitXLeft < 500 * GEO.EPS_SMALL then dSplitXRight = dSplitXLeft - dToolOverlapBetweenSegments dFeatureCentralLength = 0 @@ -373,7 +371,7 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) -- aggiungo eventuale punto estremo destro if bFeatureStartsOnEdgeRight then - table.insert( vFeatureSplittingPoints, ptSplitXRight) + table.insert( FeatureSplittingPoints, ptSplitXRight) end -- aggiungo punti centrali della feature @@ -384,16 +382,16 @@ function FeatureLib.GetFeatureSplittingPoints( Proc, Part, OptionalParameters) local ptOn local dCurrentPointX = dSplitXRight - i * dSplitPartsLen ptOn = Point3d( dCurrentPointX, 0, 0) - table.insert( vFeatureSplittingPoints, ptOn) + table.insert( FeatureSplittingPoints, ptOn) end end -- aggiungo eventuale punto estemo sinistro if bFeatureStartsOnEdgeLeft then - table.insert( vFeatureSplittingPoints, ptSplitXLeft) + table.insert( FeatureSplittingPoints, ptSplitXLeft) end - return vFeatureSplittingPoints + return FeatureSplittingPoints end ------------------------------------------------------------------------------------------------------------- diff --git a/LuaLibs/MachiningLib.lua b/LuaLibs/MachiningLib.lua index ab66080..2af5bfa 100644 --- a/LuaLibs/MachiningLib.lua +++ b/LuaLibs/MachiningLib.lua @@ -152,7 +152,7 @@ function MachiningLib.GetSplitMachinings( Machinings, vSplittingPoints, Part ) Machinings[nCurrentMachiningIndex].LeadOut.dEndAddLength = dEndAddLength end if not bIsLastSegment then - Machinings[nCurrentMachiningIndex].bMoveAfterSplitcut = false + Machinings[nCurrentMachiningIndex].sStage = '' end Machinings[nCurrentMachiningIndex].nSegment = j end @@ -642,7 +642,7 @@ function MachiningLib.AddOperations( vProc, Part, sRotation) -- TODO è giusto inserire queste info alla fine della lavorazione? oppure conviene creare un record in MACHININGS apposito per la disposizione? -- se era taglio di separazione, aggiungo nuova fase - if MACHININGS[i].AuxiliaryData.bAddNewPhase then + if MACHININGS[i].AuxiliaryData.bIsSplitOrCut then bSplitExecuted = true BeamLib.AddPhaseWithRawParts( MACHININGS[i].Proc.idRaw, BeamData.ptOriXR, BeamData.dPosXR, BeamData.RAW_OFFSET) -- se grezzo successivo senza pezzi e finale, va tolto diff --git a/LuaLibs/StrategyLib.lua b/LuaLibs/StrategyLib.lua index 3cfdaa0..221df6a 100644 --- a/LuaLibs/StrategyLib.lua +++ b/LuaLibs/StrategyLib.lua @@ -239,7 +239,7 @@ function StrategyLib.SplitStrategy.Execute( Proc, Part, Strategy) OptionalParameters.dLongitudinalOffset = Strategy.dOffset or 0 OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') - Machining.AuxiliaryData.bAddNewPhase = true + Machining.AuxiliaryData.bIsSplitOrCut = true local EdgeToMachine = StrategyLib.SplitStrategy.GetEdgeToMachine( Proc, -Y_AX()) -- approccio e retrazione @@ -279,7 +279,7 @@ function StrategyLib.SplitStrategy.Execute( Proc, Part, Strategy) OptionalParameters.dRadialOffset = ( Part.dWidth - BeamData.CUT_EXTRA) / 2 OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') - Machining.AuxiliaryData.bAddNewPhase = true + Machining.AuxiliaryData.bIsSplitOrCut = true EdgeToMachine = StrategyLib.SplitStrategy.GetEdgeToMachine( Proc, Y_AX()) -- approccio e retrazione @@ -299,7 +299,7 @@ function StrategyLib.SplitStrategy.Execute( Proc, Part, Strategy) OptionalParameters.dRadialOffset = -BeamData.CUT_EXTRA OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') - Machining.AuxiliaryData.bAddNewPhase = true + Machining.AuxiliaryData.bIsSplitOrCut = true local EdgeToMachine = StrategyLib.SplitStrategy.GetEdgeToMachine( Proc, Z_AX()) -- approccio e retrazione @@ -340,7 +340,7 @@ function StrategyLib.SplitStrategy.Execute( Proc, Part, Strategy) OptionalParameters.dRadialOffset = Part.dHeight - Strategy.SplitStrategy[2].ToolInfo.dMaxMatBladeFromDown + dExtraMaxMat OptionalParameters.sUserNotes = EgtIf( Strategy.bSplit, 'Split;', 'Cut;') - Machining.AuxiliaryData.bAddNewPhase = true + Machining.AuxiliaryData.bIsSplitOrCut = true EdgeToMachine = StrategyLib.SplitStrategy.GetEdgeToMachine( Proc, -Z_AX()) -- approccio e retrazione diff --git a/Process.lua b/Process.lua index 9ac513c..071ebc6 100644 --- a/Process.lua +++ b/Process.lua @@ -131,15 +131,15 @@ local function MyProcessInputData() EgtOutBox( 'Box non definito per la trave ' .. PARTS[i].sName, 'Lavora Travi', 'ERROR') return false else - PARTS[i].b3Box = b3Solid + PARTS[i].b3Part = b3Solid end end - dRawW = PARTS[1].b3Box:getDimY() - dRawH = PARTS[1].b3Box:getDimZ() + dRawW = PARTS[1].b3Part:getDimY() + dRawH = PARTS[1].b3Part:getDimZ() local vBeamErr = {} for i = 2, #PARTS do - local dDimW = PARTS[i].b3Box:getDimY() - local dDimH = PARTS[i].b3Box:getDimZ() + local dDimW = PARTS[i].b3Part:getDimY() + local dDimH = PARTS[i].b3Part:getDimZ() if ( abs( dDimW - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimH - dRawH) > 10 * GEO.EPS_SMALL) and ( abs( dDimH - dRawW) > 10 * GEO.EPS_SMALL or abs( dDimW - dRawH) > 10 * GEO.EPS_SMALL) then table.insert( vBeamErr, i) @@ -186,9 +186,9 @@ local function MyProcessBeams() -- Lunghezza totale delle travi local dTotLen = 0 for i = 1, #PARTS - 1 do - dTotLen = dTotLen + PARTS[i].b3Box:getDimX() + dTotLen = dTotLen + PARTS[i].b3Part:getDimX() end - dTotLen = dTotLen + max( PARTS[#PARTS].b3Box:getDimX(), BeamData.dMinRaw) + dTotLen = dTotLen + max( PARTS[#PARTS].b3Part:getDimX(), BeamData.dMinRaw) local dAddLen = BeamData.OVM_HEAD + ( #PARTS - 1) * BeamData.OVM_MID EgtOutLog( 'Ltot : '..EgtNumToString( dTotLen, 1) .. ' Lagg : '..EgtNumToString( dAddLen, 1)..' MinUnloadRaw : '.. EgtNumToString( BeamData.dMinRaw + BeamData.OVM_MID, 1), 1) @@ -277,10 +277,10 @@ local function MyProcessBeams() local bOrd = ( vsVal[5] == 'true') if bOrd then table.sort( PARTS, function( B1, B2) - if abs( B1.b3Box:getDimX() - B2.b3Box:getDimX()) < 1 then + if abs( B1.b3Part:getDimX() - B2.b3Part:getDimX()) < 1 then return B1.nInd < B2.nInd else - return B1.b3Box:getDimX() < B2.b3Box:getDimX() + return B1.b3Part:getDimX() < B2.b3Part:getDimX() end end) end diff --git a/Strategies/Core/SLOTBYBLADE.lua b/Strategies/Core/SLOTBYBLADE.lua index 440630d..9808817 100644 --- a/Strategies/Core/SLOTBYBLADE.lua +++ b/Strategies/Core/SLOTBYBLADE.lua @@ -257,13 +257,13 @@ function SLOTBYBLADE.Make( Proc, Part, FaceToMachine, EdgeToMachine, OptionalPar end if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then - Cutting.bMoveAfterSplitcut = true + Cutting.sStage = 'AfterTail' else Cutting.bIsApplicable = false end elseif dAddLengthLeftSide + dAddLengthToReduce > dExtendAfterTail then if MachiningLib.CanMoveAfterSplitcut( Cutting.dLengthOnX, Part) then - Cutting.bMoveAfterSplitcut = true + Cutting.sStage = 'AfterTail' else if bStartLeft then Cutting.LeadIn.dStartAddLength = - dAddLengthToReduce + dExtendAfterTail diff --git a/Strategies/Core/SLOTBYCHAINSAW.lua b/Strategies/Core/SLOTBYCHAINSAW.lua index 3691f12..019a94b 100644 --- a/Strategies/Core/SLOTBYCHAINSAW.lua +++ b/Strategies/Core/SLOTBYCHAINSAW.lua @@ -232,13 +232,13 @@ function SLOTBYCHAINSAW.Make( Proc, Part, FaceToMachine, EdgeToMachine, Optional end if not AreSameOrOppositeVectorApprox( EdgeToMachine.vtToolDirection, Y_AX()) then if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then - Mortising.bMoveAfterSplitcut = true + Mortising.sStage = 'AfterTail' else Mortising.bIsApplicable = false end elseif dAddLengthLeftSide + TOOLS[Mortising.nToolIndex].dDiameter / 2 > dExtendAfterTail then if MachiningLib.CanMoveAfterSplitcut( Mortising.dLengthOnX, Part) then - Mortising.bMoveAfterSplitcut = true + Mortising.sStage = 'AfterTail' else if bStartLeft then Mortising.LeadIn.dStartAddLength = - TOOLS[Mortising.nToolIndex].dDiameter / 2 + dExtendAfterTail diff --git a/Strategies/Standard/HEADCUT/HEADCUT.lua b/Strategies/Standard/HEADCUT/HEADCUT.lua index 984db86..6ad6bd2 100644 --- a/Strategies/Standard/HEADCUT/HEADCUT.lua +++ b/Strategies/Standard/HEADCUT/HEADCUT.lua @@ -279,6 +279,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeSideDouble' then @@ -295,6 +296,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) -- Taglio lato dietro @@ -312,6 +314,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalSingle' then @@ -327,6 +330,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'BladeHorizontalDouble' then @@ -344,6 +348,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) -- Taglio lato dietro @@ -361,6 +366,7 @@ function HEADCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- approccio e retrazione OptionalParameters.LeadIn, OptionalParameters.LeadOut = CalculateLeadInOut( Splitting, EdgeToMachine) Splitting = FaceByBlade.Make( Proc, Part, Proc.Faces[1].id, EdgeToMachine, OptionalParameters) + Splitting.sStage = 'Head' MachiningLib.AddNewMachining( Proc, Splitting, AuxiliaryData) ---------------------------------------------------------------------------------- elseif Strategy.sSplitStrategy.sTypeMachining == 'ChainSawHorizontal' then diff --git a/Strategies/Standard/STR0002/STR0002.lua b/Strategies/Standard/STR0002/STR0002.lua index c8a54c0..dda384a 100644 --- a/Strategies/Standard/STR0002/STR0002.lua +++ b/Strategies/Standard/STR0002/STR0002.lua @@ -360,29 +360,29 @@ local function GetSplitSurfaces( Proc, Part) end -- recupero punti di spezzatura - da destra a sinistra - local vFeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #vFeatureSplittingPoints == 0 then + if #FeatureSplittingPoints == 0 then local nAddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL local nAddIdTunnel = EgtCopyGlob( nOriginalTmIdTunnel, nAddGrpId) or GDB_ID.NULL table.insert( vAddId, nAddId) table.insert( vAddIdTunnel, nAddIdTunnel) else - for i = 1, #vFeatureSplittingPoints do + for i = 1, #FeatureSplittingPoints do local nAddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL local nAddIdTunnel = EgtCopyGlob( nOriginalTmIdTunnel, nAddGrpId) or GDB_ID.NULL if i == 1 then -- prima superficie, va tagliata solo a sinistra - local ptSplit = vFeatureSplittingPoints[i] + Vector3d( -BeamData.MILL_OVERLAP / 2, 0, 0) + local ptSplit = FeatureSplittingPoints[i] + Vector3d( -BeamData.MILL_OVERLAP / 2, 0, 0) EgtCutSurfTmPlane( nAddId, ptSplit, -X_AX(), true, GDB_RT.GLOB) EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, -X_AX(), true, GDB_RT.GLOB) else -- taglio della superficie corrente - lato sinistro - local ptSplit = vFeatureSplittingPoints[i] + Vector3d( -BeamData.MILL_OVERLAP / 2, 0, 0) + local ptSplit = FeatureSplittingPoints[i] + Vector3d( -BeamData.MILL_OVERLAP / 2, 0, 0) EgtCutSurfTmPlane( nAddId, ptSplit, -X_AX(), true, GDB_RT.GLOB) EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, -X_AX(), true, GDB_RT.GLOB) -- taglio della superficie corrente - lato destro - ptSplit = vFeatureSplittingPoints[i - 1] + Vector3d( BeamData.MILL_OVERLAP / 2, 0, 0) + ptSplit = FeatureSplittingPoints[i - 1] + Vector3d( BeamData.MILL_OVERLAP / 2, 0, 0) EgtCutSurfTmPlane( nAddId, ptSplit, X_AX(), true, GDB_RT.GLOB) EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, X_AX(), true, GDB_RT.GLOB) end @@ -392,7 +392,7 @@ local function GetSplitSurfaces( Proc, Part) -- taglio ultima superficie, va tagliata solo a destra local nAddId = EgtCopyGlob( Proc.id, nAddGrpId) or GDB_ID.NULL local nAddIdTunnel = EgtCopyGlob( nOriginalTmIdTunnel, nAddGrpId) or GDB_ID.NULL - local ptSplit = vFeatureSplittingPoints[#vFeatureSplittingPoints] + Vector3d( BeamData.MILL_OVERLAP / 2, 0, 0) + local ptSplit = FeatureSplittingPoints[#FeatureSplittingPoints] + Vector3d( BeamData.MILL_OVERLAP / 2, 0, 0) EgtCutSurfTmPlane( nAddId, ptSplit, X_AX(), true, GDB_RT.GLOB) EgtCutSurfTmPlane( nAddIdTunnel, ptSplit, X_AX(), true, GDB_RT.GLOB) table.insert( vAddId, nAddId) diff --git a/Strategies/Standard/STR0003/STR0003.lua b/Strategies/Standard/STR0003/STR0003.lua index 6ccdf7f..c7d453b 100644 --- a/Strategies/Standard/STR0003/STR0003.lua +++ b/Strategies/Standard/STR0003/STR0003.lua @@ -303,9 +303,9 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- lama - lavorazioni raggruppate in unica lista Blade.Result.Sorted = MergeResults( Blade.Result) -- lama - aggiunta eventuali lavorazioni splittate - local vFeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #vFeatureSplittingPoints > 0 then - Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, vFeatureSplittingPoints, Part) + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + if #FeatureSplittingPoints > 0 then + Blade.Result.Sorted = MachiningLib.GetSplitMachinings( Blade.Result.Sorted, FeatureSplittingPoints, Part) end -- lama - nessuna lavorazione successiva - aggiunta lavorazioni e calcolo risultati if not Strategy.Parameters.bFinishWithChainSaw then @@ -500,8 +500,8 @@ function STR0003.Make( bAddMachining, Proc, Part, CustomParameters) -- sega a catena - lavorazioni raggruppate in unica lista Chainsaw.Result.Sorted = MergeResults( Chainsaw.Result) -- sega a catena - aggiunta eventuali lavorazioni splittate - if #vFeatureSplittingPoints > 0 then - Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, vFeatureSplittingPoints, Part) + if #FeatureSplittingPoints > 0 then + Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, FeatureSplittingPoints, Part) end -- tutte le lavorazioni di tutti gli utensili in unica lista diff --git a/Strategies/Standard/STR0004/STR0004.lua b/Strategies/Standard/STR0004/STR0004.lua index 3a9604f..e41fb5d 100644 --- a/Strategies/Standard/STR0004/STR0004.lua +++ b/Strategies/Standard/STR0004/STR0004.lua @@ -234,9 +234,9 @@ function STR0004.Make( bAddMachining, Proc, Part, CustomParameters) end -- aggiunta eventuali lavorazioni splittate - local vFeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) - if #vFeatureSplittingPoints > 0 then - Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, vFeatureSplittingPoints, Part) + local FeatureSplittingPoints = FeatureLib.GetFeatureSplittingPoints( Proc, Part) + if #FeatureSplittingPoints > 0 then + Chainsaw.Result.Sorted = MachiningLib.GetSplitMachinings( Chainsaw.Result.Sorted, FeatureSplittingPoints, Part) end -- ordinamento diff --git a/Strategies/Standard/TAILCUT/TAILCUT.lua b/Strategies/Standard/TAILCUT/TAILCUT.lua index 184c551..2b4aa1e 100644 --- a/Strategies/Standard/TAILCUT/TAILCUT.lua +++ b/Strategies/Standard/TAILCUT/TAILCUT.lua @@ -89,6 +89,7 @@ function TAILCUT.Make( bAddMachining, Proc, Part, CustomParameters) -- aggiungo lavorazioni trovate alla lista generale for i = 1, #MachiningsToAdd do + MachiningsToAdd[i].Splitting.sStage = 'Tail' MachiningLib.AddNewMachining( Proc, MachiningsToAdd[i].Splitting, MachiningsToAdd[i].AuxiliaryData) end