diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 190bcac..147a01b 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Sawing.cpp b/Sawing.cpp index ea9ac93..ea5053c 100644 --- a/Sawing.cpp +++ b/Sawing.cpp @@ -56,6 +56,15 @@ using namespace std ; // 2218 = "Error in Sawing : link outstroke xxx" // 2219 = "Error in Sawing : post apply not calculable" +//---------------------------------------------------------------------------- +struct FseVar { + double dLenStart ; + double dPuStart ; + double dLenEnd ; + double dPuEnd ; + FseVar( void) : dLenStart( 0), dPuStart( 0), dLenEnd( 0), dPuEnd( 0) {} +} ; + //---------------------------------------------------------------------------- USEROBJ_REGISTER( GetOperationClass( OPER_SAWING), Sawing) ; @@ -1502,6 +1511,31 @@ Sawing::ProcessLine( const ICurve* pCrvP, const ICurveLine* pLineC, const ICurve return true ; } + // Eventuale variazioni di velocità all'inizio e alla fine del percorso + FseVar FvVar ; + if ( pCrvP == nullptr) { + string sFsta = ExtractInfo( m_Params.m_sUserNotes, "Fsta:") ; + if ( ! sFsta.empty()) { + string sLen, sPu ; + SplitFirst( sFsta, "=", sLen, sPu) ; + FromString( sLen, FvVar.dLenStart) ; + FvVar.dLenStart = max( FvVar.dLenStart, 0.) ; + FromString( sPu, FvVar.dPuStart) ; + FvVar.dPuStart = max( FvVar.dPuStart, 0.) ; + } + } + if ( pCrvN == nullptr) { + string sFend = ExtractInfo( m_Params.m_sUserNotes, "Fend:") ; + if ( ! sFend.empty()) { + string sLen, sPu ; + SplitFirst( sFend, "=", sLen, sPu) ; + FromString( sLen, FvVar.dLenEnd) ; + FvVar.dLenEnd = max( FvVar.dLenEnd, 0.) ; + FromString( sPu, FvVar.dPuEnd) ; + FvVar.dPuEnd = max( FvVar.dPuEnd, 0.) ; + } + } + // Se richiesto Preview if ( nPvId != GDB_ID_NULL) { if ( ! GenerateLinePv( pLine, vtTool, vtCorr, dElev, dExtraCut, dRbHeight, sName, nPvId)) @@ -1510,7 +1544,7 @@ Sawing::ProcessLine( const ICurve* pCrvP, const ICurveLine* pLineC, const ICurve // Se richiesta geometria di lavorazione if ( nClId != GDB_ID_NULL) { - if ( ! GenerateLineCl( pLine, vtTool, vtCorr, dElev, dExtraCut, sName, dDeltaLiExt, dDeltaLoExt, nClId)) + if ( ! GenerateLineCl( pLine, vtTool, vtCorr, dElev, dExtraCut, sName, dDeltaLiExt, dDeltaLoExt, FvVar, nClId)) return false ; } @@ -1659,7 +1693,8 @@ Sawing::GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const V //---------------------------------------------------------------------------- bool Sawing::GenerateLineCl( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, - double dElev, double dExtraCut, const string& sName, double dDeltaLiExt, double dDeltaLoExt, int nClId) + double dElev, double dExtraCut, const string& sName, + double dDeltaLiExt, double dDeltaLoExt, const FseVar& FvVar, int nClId) { // creo gruppo per geometria di lavorazione della linea int nPxId = m_pGeomDB->AddGroup( GDB_ID_NULL, nClId, Frame3d()) ; @@ -1707,10 +1742,44 @@ Sawing::GenerateLineCl( const ICurveLine* pLine, const Vector3d& vtTool, const V if ( AddLinearMove( ptP2) == GDB_ID_NULL) return false ; // 3 -> movimento di lato al punto finale - SetFeed( GetFeed()) ; - Point3d ptP3 = pLine->GetEnd() ; - if ( AddLinearMove( ptP3) == GDB_ID_NULL) - return false ; + if ( FvVar.dLenStart > EPS_SMALL || FvVar.dLenEnd > EPS_SMALL) { + // lunghezza del taglio + double dCutLen ; pLine->GetLength( dCutLen) ; + double dStartFraz = FvVar.dLenStart / dCutLen ; + double dEndFraz = FvVar.dLenEnd / dCutLen ; + double dMidFraz = 1 - dEndFraz ; + if ( dStartFraz + dEndFraz > 1) { + dStartFraz /= ( dStartFraz + dEndFraz) ; + dEndFraz = 1 - dStartFraz ; + dMidFraz = dStartFraz ; + } + // punto finale + Point3d ptP3 = pLine->GetEnd() ; + // 3a -> eventuale movimento di lato a feed ridotta di inizio percorso + if ( dStartFraz * dCutLen > EPS_SMALL) { + SetFeed( FvVar.dPuStart * GetFeed()) ; + if ( AddLinearMove( Media( ptP2, ptP3, dStartFraz)) == GDB_ID_NULL) + return false ; + } + // 3b -> eventuale movimento di lato a feed normale + if ( ( dMidFraz - dStartFraz) * dCutLen > EPS_SMALL) { + SetFeed( GetFeed()) ; + if ( AddLinearMove( Media( ptP2, ptP3, dMidFraz)) == GDB_ID_NULL) + return false ; + } + // 3c -> eventuale movimento di lato a feed ridotta di fine percorso + if ( dEndFraz * dCutLen > EPS_SMALL) { + SetFeed( FvVar.dPuEnd * GetFeed()) ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } + } + else { + SetFeed( GetFeed()) ; + Point3d ptP3 = pLine->GetEnd() ; + if ( AddLinearMove( ptP3) == GDB_ID_NULL) + return false ; + } // 4 -> retrazione if ( ! AddRetract( pLine->GetEnd(), vtCorr, dSafeZ, dElev, dAppr)) return false ; diff --git a/Sawing.h b/Sawing.h index 49cde58..e8dc308 100644 --- a/Sawing.h +++ b/Sawing.h @@ -22,6 +22,7 @@ class ICurve ; class ICurveLine ; class ICurveArc ; class ICurveComposite ; +struct FseVar ; //---------------------------------------------------------------------------- class Sawing : public Machining @@ -82,7 +83,7 @@ class Sawing : public Machining bool GenerateLinePv( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, double dElev, double dExtraCut, double dRbHeight, const string& sName, int nPvId) ; bool GenerateLineCl( const ICurveLine* pLine, const Vector3d& vtTool, const Vector3d& vtCorr, - double dElev, double dExtraCut, const string& sName, double dDeltaLiExt, double dDeltaLoExt, int nClId) ; + double dElev, double dExtraCut, const string& sName, double dDeltaLiExt, double dDeltaLoExt, const FseVar& FvVar, int nClId) ; bool ProcessExtCurve( const ICurve* pCrvP, const ICurveComposite* pCrvC, const ICurve* pCrvN, double dDepth, double dExtraCut, double dRbHeight, bool bIsFirst, bool bIsLast, const string& sName, int nPvId, int nClId) ;