diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 9dac4fb..dba24b9 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/MachConst.h b/MachConst.h index e8728c2..f8f9732 100644 --- a/MachConst.h +++ b/MachConst.h @@ -148,6 +148,7 @@ const double RAW_MIN_H = 1 ; //---------------------------------------------------------------------------- // Minima feed const double FEED_MIN = 1 ; +constexpr double FEED_MAX_REDUCE = 5 ; //---------------------------------------------------------------------------- // Massimo angolo al centro per archi di CL diff --git a/OperUserNotesConst.h b/OperUserNotesConst.h index b9634e3..6cc91d0 100644 --- a/OperUserNotesConst.h +++ b/OperUserNotesConst.h @@ -52,6 +52,7 @@ static const std::string UN_OPENMINSAFE = "OpenMinSafe" ; static const std::string UN_MAXOPTSIZE = "MaxOptSize" ; static const std::string UN_PROJEXT = "ExtProj" ; static const std::string UN_ADJUSTFEED = "AdjustFeed" ; +static const std::string UN_MINFEED = "MinFeed" ; // Solo per Sawing static const std::string UN_DOWNSE = "DownSE" ; @@ -73,6 +74,7 @@ static const std::string UN_ANGLETOL = "AngleTol" ; static const std::string UN_PLANEZ = "PlaneZ" ; static const std::string UN_ORDER = "Order" ; static const std::string UN_SUPP_RAD_OFFS = "SuppRadOffs" ; + // come per PocketingNT, viene usato il parametro UN_MINFEED // Solo per Waterjetting static const std::string UN_START = "START" ; diff --git a/PocketingNT.cpp b/PocketingNT.cpp index 2a509b3..cd264ea 100644 --- a/PocketingNT.cpp +++ b/PocketingNT.cpp @@ -130,6 +130,7 @@ static double TOOL_RAD_PTSTART = 20. ; #include "EgtDev/Include/EGkGeoPoint3d.h" #include "EgtDev/Include/EGkGeoVector3d.h" #include "EgtDev/Include/EGkFrame3d.h" + int nGrpDebugFeed = GDB_ID_NULL, nLayDebugFeed = GDB_ID_NULL ; #endif //---------------------------------------------------------------------------- @@ -2358,12 +2359,17 @@ PocketingNT::GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const PtrOwner pCompoLoop( ConvertCurveToComposite( pSfr->GetLoop( nC, nL))) ; if ( IsNull( pCompoLoop) || ! pCompoLoop->IsValid()) return P_INVALID ; + // verifico se la curva è tutta chiusa + ICRVCOMPOPOVECTOR vpCrvs ; + bool bClosePock = ( GetHomogeneousParts( pCompoLoop, vpCrvs) && + ssize( vpCrvs) == 1 && vpCrvs[0]->GetTempProp( 0) == TEMP_PROP_CLOSE_EDGE) ; // scorro le sue curve for ( int nU = 0 ; nU < pCompoLoop->GetCurveCount() ; ++ nU) { const ICurve* pCrv = pCompoLoop->GetCurve( nU) ; if ( pCrv == nullptr || ! pCrv->IsValid()) return P_INVALID ; - if ( pCrv->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE) { + // scorro il lato corrente ( in generale aperto, chiuso solo se bordo tutto chiuso) + if ( pCrv->GetTempProp( 0) == TEMP_PROP_OPEN_EDGE || bClosePock) { // calcolo il Box globale della curva e memorizzo la componente Z ( media) BBox3d BBoxGlob ; if ( pCrv->GetLocalBBox( BBoxGlob)) { @@ -2400,7 +2406,7 @@ PocketingNT::GetStartPointsByHead( const STEPINFOPOVECTOR& vStepInfo) const m_pGeomDB->SetMaterial( _nCrv, YELLOW) ; } #endif - // se non ho candidate, non ho un punto di riferimento + // se non ho candidate, verifico se la tasca è tutta chiusa ( dato che un aperto disponibile per l'entrata non è stato trovato) if ( vIndCrv.empty()) return P_INVALID ; int nChunk = 0, nLoop = 0, nCurve = 0 ; @@ -3537,7 +3543,6 @@ PocketingNT::CalcGeoExtSurfFr( const ISurfFlatRegion* pSfrPock, const Vector3d& // recupero tutte le facce adiacenti alla faccia selezionata INTSET setAdjFace ; for ( int i = 0 ; i < ssize( vPL) ; ++ i) { - int nInd = 0 ; double dPar ; bool bFound = vPL[i].GetFirstU( dPar, true) ; while ( bFound) { @@ -3554,7 +3559,6 @@ PocketingNT::CalcGeoExtSurfFr( const ISurfFlatRegion* pSfrPock, const Vector3d& setAdjFace.insert( nFlag) ; } // passo al successivo - ++ nInd ; bFound = vPL[i].GetNextU( dPar, true) ; } } @@ -4751,9 +4755,9 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou if ( ! CalcPaths( vStepInfo)) return false ; #if DEBUG_FEED - int nGrp = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ; - int nLay = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrp, GLOB_FRM) ; - m_pGeomDB->SetName( nGrp, "Feed") ; + nGrpDebugFeed = m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, GLOB_FRM) ; + nLayDebugFeed = m_pGeomDB->AddGroup( GDB_ID_NULL, nGrpDebugFeed, GLOB_FRM) ; + m_pGeomDB->SetName( nGrpDebugFeed, "Feed") ; #endif // recupero distanze di sicurezza @@ -4771,6 +4775,11 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou // punto finale del percorso per ogni Chunk di lavorazione Point3d ptEnd = P_INVALID ; + // recupero parametro di Feed minima + double dMinFeed = GetFeed() / FEED_MAX_REDUCE ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_MINFEED, dMinFeed)) + dMinFeed = Clamp( dMinFeed, GetFeed() / FEED_MAX_REDUCE, GetFeed()) ; + // scorro il vettore dei piani di pocketing for ( int i = 0 ; i < int( vStepInfo.size()) ; ++ i) { // riferimento alle informazioni relative allo step i-esimo @@ -4868,8 +4877,20 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou // aggiungo LeadIn ( se necessario effettuo movimento di riposizionamento verso ptP1) SetFeed( GetStartFeed()) ; Point3d ptCurr ; GetCurrPos( ptCurr) ; - if ( ! AreSamePointApprox( ptP1, ptCurr)) + if ( ! AreSamePointApprox( ptP1, ptCurr)) { + Vector3d vtMove = ptP1 - ptCurr ; vtMove.Normalize() ; + double dElev = 0. ; + bool bInMaterial = true ; + if ( GetElevation( m_nPhase, ptCurr, ptP1, vtTool, GetRadiusForStartEndElevation(), m_TParams.m_dLen, vtTool, dElev) && + dElev < 10. * EPS_SMALL) + bInMaterial = false ; + SetFeed( bInMaterial ? GetRightFeed( vtMove, vtTool) : GetStartFeed()) ; + #if DEBUG_FEED + PtrOwner pLine( CreateCurveLine()) ; pLine->Set( ptCurr, ptP1) ; + DebugDrawFeed( pLine->Clone(), bInMaterial ? GetRightFeed( vtMove, vtTool) : GetStartFeed(), nLayDebugFeed) ; + #endif AddLinearMove( ptP1) ; + } bool bNoneForced = ( currPath.bOutStart || currPath.bSingleCrv || ( m_Params.m_nSubType == POCKET_SUB_ZIGZAG && ! currPath.bIsZigZagOneWayBorder) || ( m_Params.m_nSubType == POCKET_SUB_ONEWAY && ! currPath.bIsZigZagOneWayBorder)) ; @@ -4885,18 +4906,17 @@ PocketingNT::AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, dou if ( pCurve->GetType() == CRV_LINE) { ICurveLine* pLine = GetCurveLine( pCurve) ; Point3d ptP3 = pLine->GetEnd() ; - Vector3d vtMove ; pLine->GetStartDir( vtMove) ; - SetFeed( dCoeffFeed * GetRightFeed( vtMove, vtTool)) ; + SetFeed( Clamp( dCoeffFeed * GetFeed(), dMinFeed, GetFeed())) ; #if DEBUG_FEED - DebugDrawFeed( pCurve->Clone(), dCoeffFeed * GetRightFeed( vtMove, vtTool), nLay) ; + DebugDrawFeed( pCurve->Clone(), dCoeffFeed * GetFeed(), nLayDebugFeed) ; #endif if ( AddLinearMove( ptP3, bSplitArcs) == GDB_ID_NULL) return false ; } else { - SetFeed( dCoeffFeed * GetFeed()) ; + SetFeed( Clamp( dCoeffFeed * GetFeed(), dMinFeed, GetFeed())) ; #if DEBUG_FEED - DebugDrawFeed( pCurve->Clone(), dCoeffFeed * GetFeed(), nLay) ; + DebugDrawFeed( pCurve->Clone(), dCoeffFeed * GetFeed(), nLayDebugFeed) ; #endif if ( AddCurveMove( pCurve, bSplitArcs) == GDB_ID_NULL) return false ; @@ -5106,6 +5126,24 @@ PocketingNT::GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) return min( GetFeed(), GetTipFeed() / abs( dCosMove)) ; } +//------------------------------------------------------------------ +double +PocketingNT::GetRightStartFeed( const Vector3d& vtMove, const Vector3d& vtTool) +{ + // Determino i versori + Vector3d vtM = vtMove ; + vtM.Normalize() ; + Vector3d vtT = vtTool ; + vtT.Normalize() ; + // Angolo tra movimento e versore utensile + double dCosMove = vtM * vtT ; + // Se l'utensile non ha movimento significativo di punta, si restituisce la feed standard + if ( dCosMove > - COS_ORTO_ANG_SMALL) + return GetStartFeed() ; + // Altrimenti non si deve superare la massima velocità di punta prevista + return min( GetStartFeed(), GetTipFeed() / abs( dCosMove)) ; +} + //------------------------------------------------------------------ bool PocketingNT::CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) @@ -5648,6 +5686,12 @@ PocketingNT::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vecto PtrOwner pArc( CreateCurveArc()) ; if ( IsNull( pArc) || ! pArc->Set( ptCen, vtN, dRad, - vtCen, dAngCen, dDeltaN)) return false ; + // dovendo creare l'elica, sono nel materiale, quindi regolo la Feed + Vector3d vtTanHelix ; pArc->GetStartDir( vtTanHelix) ; + SetFeed( GetRightStartFeed( vtTanHelix, vtN)) ; + #if DEBUG_FEED + DebugDrawFeed( pArc->Clone(), GetRightStartFeed( vtTanHelix, vtN), nLayDebugFeed) ; + #endif // emetto l'elica (con eventuale spezzatura) return ( AddCurveMove( pArc, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ; } @@ -5663,17 +5707,33 @@ PocketingNT::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vecto double dStep = - dDeltaN / nStep ; Point3d ptPa = ptP1 + vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; Point3d ptPb = ptP1 - vtStart * 0.5 * min( m_Params.m_dLiTang, m_TParams.m_dDiam) ; + Vector3d vtTanZigZag = ( ptPa - vtN * 0.25 * dStep) - ptP1 ; + SetFeed( GetRightStartFeed( vtTanZigZag, vtN)) ; // verifico se fattibile if ( bSkipControl || VerifyLeadInZigZag( pSfr, ptStart, ptPa, ptPb)) { for ( int i = 1 ; i <= nStep ; ++ i) { + #if DEBUG_FEED + PtrOwner pLine( CreateCurveLine()) ; + Point3d ptCurr ; GetCurrPos( ptCurr) ; pLine->Set( ptCurr, ptPa - vtN * ( i - 0.75) * dStep) ; + DebugDrawFeed( pLine->Clone(), GetRightStartFeed( vtTanZigZag, vtN), nLayDebugFeed) ; + #endif if ( AddLinearMove( ptPa - vtN * ( i - 0.75) * dStep, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL) return false ; + #if DEBUG_FEED + GetCurrPos( ptCurr) ; pLine->Set( ptCurr, ptPb - vtN * ( i - 0.25) * dStep) ; + DebugDrawFeed( pLine->Clone(), GetRightStartFeed( vtTanZigZag, vtN), nLayDebugFeed) ; + #endif if ( AddLinearMove( ptPb - vtN * ( i - 0.25) * dStep, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL) return false ; } + #if DEBUG_FEED + PtrOwner pLine( CreateCurveLine()) ; + Point3d ptCurr ; GetCurrPos( ptCurr) ; pLine->Set( ptCurr, ptStart) ; + DebugDrawFeed( pLine->Clone(), GetRightStartFeed( vtTanZigZag, vtN), nLayDebugFeed) ; + #endif return ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ; } - // altrimenti diretto + // altrimenti diretto ( controllo semplicemente se posso entrare di testa) else { nType = POCKET_LI_NONE ; if ( m_TParams.m_nType == TT_MILL_NOTIP) @@ -5688,12 +5748,18 @@ PocketingNT::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vecto if ( IsNull( pCrv) || ! pCrv->IsValid()) return false ; pCrv->SetExtrusion( vtN) ; - // la porto alla giusta quota - Point3d ptFin ; pCrv->GetEndPoint( ptFin) ; // assegno la corretta pendenza double dNini = ( ptP1 - ORIG) * vtN ; double dNfin = ( ptStart - ORIG) * vtN ; AdjustCurveSlope( pCrv, dNini, dNfin) ; + // assegno le Feed + Point3d ptS ; pCrv->GetStartPoint( ptS) ; + Point3d ptE ; pCrv->GetEndPoint( ptE) ; + Vector3d vtMove = ptE - ptS ; + SetFeed( GetRightStartFeed( vtMove, vtN)) ; + #if DEBUG_FEED + DebugDrawFeed( pCrv->Clone(), GetRightStartFeed( vtMove, vtN), nLayDebugFeed) ; + #endif // emetto (con eventuale spezzatura) return ( AddCurveMove( pCrv, bSplitArcs, MCH_CL_LEADIN) != GDB_ID_NULL) ; } @@ -5706,6 +5772,17 @@ PocketingNT::AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vecto Point3d ptCurr = ptP1 ; GetCurrPos( ptCurr) ; if ( ! AreSamePointApprox( ptCurr, ptStart)) { + Vector3d vtMove = ptStart - ptCurr ; vtMove.Normalize() ; + double dElev = 0. ; + bool bInMaterial = true ; + if ( GetElevation( m_nPhase, ptCurr, ptStart, vtN, GetRadiusForStartEndElevation(), m_TParams.m_dLen, vtN, dElev) && dElev < 10. * EPS_SMALL) + bInMaterial = false ; + // Feed di Testa + SetFeed( bInMaterial ? GetTipFeed() : GetStartFeed()) ; + #if DEBUG_FEED + PtrOwner pLine( CreateCurveLine()) ; pLine->Set( ptCurr, ptStart) ; + DebugDrawFeed( pLine->Clone(), bInMaterial ? GetTipFeed() : GetStartFeed(), nLayDebugFeed) ; + #endif if ( AddLinearMove( ptStart, bSplitArcs, MCH_CL_LEADIN) == GDB_ID_NULL) return false ; } @@ -6142,7 +6219,10 @@ PocketingNT::DebugDrawFeed( const ICurve* pCrv, double dFeed, int nLay) if ( pCrv == nullptr || ! pCrv->IsValid()) return ; - double dMinFeed = GetFeed() * GetSideStep() / m_TParams.m_dDiam ; + // recupero parametro di Feed minima + double dMinFeed = GetFeed() / FEED_MAX_REDUCE ; + if ( GetValInNotes( m_Params.m_sUserNotes, UN_MINFEED, dMinFeed)) + dMinFeed = Clamp( dMinFeed, GetFeed() / FEED_MAX_REDUCE, GetFeed()) ; double myAngle = 120 * ( ( ( dFeed - dMinFeed) / ( GetFeed() - dMinFeed))) ; int nInd = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nLay, pCrv->Clone()) ; m_pGeomDB->SetMaterial( nInd, GetColorFromHSV( HSV( myAngle, 1., 1.))) ; diff --git a/PocketingNT.h b/PocketingNT.h index 18e3d17..bd02882 100644 --- a/PocketingNT.h +++ b/PocketingNT.h @@ -137,6 +137,7 @@ class PocketingNT : public Machining const Vector3d& vtTool, bool bHolePocketing, bool bInVsOut, ICurveComposite* pCrvGlide) ; bool AddPocket( STEPINFOPOVECTOR& vStepInfo, const Vector3d& vtTool, double dStep, bool bSplitArcs, Point3d& ptPockStart, Point3d& ptPockEnd) ; double GetRightFeed( const Vector3d& vtMove, const Vector3d& vtTool) ; + double GetRightStartFeed( const Vector3d& vtMove, const Vector3d& vtTool) ; bool CutCurveWithLine( ICurveComposite* pCrvA, const ICurveLine* pCrvB) ; bool ComputePolishingPath( ICurveComposite* pMCrv, ICurveComposite* pRCrv, bool bSplitArcs) ; bool AddEpicycles( ICurveComposite * pCompo, ICurveComposite * pCrv, ICurveComposite * pCrvBound = nullptr) ;