diff --git a/MachMgr.h b/MachMgr.h index 26913a8..582d4be 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -429,6 +429,7 @@ class MachMgr : public IMachMgr bool GetAllCurrAxesName( STRVECTOR& vAxName) const ; bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ; bool GetCurrAxisHomePos( int nInd, double& dHome) const ; + const Frame3d& GetCurrLinAxesFrame( void) const ; bool ApplyRotAxisBlock( void) ; void ClearRotAxisBlock( void) { m_vAxisBlock.clear() ; } diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 60c9097..bacd2c0 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -545,12 +545,9 @@ MachMgr::GetAllTablesNames( STRVECTOR& vNames) const { // pulisco il vettore vNames.clear() ; - // recupero la macchina corrente + // richiedo elenco tavole alla macchina corrente Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - // richiedo elenco tavole alla macchina - return pMch->GetAllTablesNames( vNames) ; + return ( ( pMch != nullptr) ? pMch->GetAllTablesNames( vNames) : false) ; } //---------------------------------------------------------------------------- @@ -559,12 +556,9 @@ MachMgr::GetAllHeadsNames( STRVECTOR& vNames) const { // pulisco il vettore vNames.clear() ; - // recupero la macchina corrente + // richiedo elenco teste alla macchina corrente Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - // richiedo elenco teste alla macchina - return pMch->GetAllHeadsNames( vNames) ; + return ( ( pMch != nullptr) ? pMch->GetAllHeadsNames( vNames) : false) ; } //---------------------------------------------------------------------------- @@ -573,12 +567,9 @@ MachMgr::GetAllTcPosNames( STRVECTOR& vNames) const { // pulisco il vettore vNames.clear() ; - // recupero la macchina corrente + // richiedo elenco posizioni cambio utensile alla macchina corrente Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - // richiedo elenco posizioni cambio utensile alla macchina - return pMch->GetAllTcPosNames( vNames) ; + return ( ( pMch != nullptr) ? pMch->GetAllTcPosNames( vNames) : false) ; } //---------------------------------------------------------------------------- @@ -621,6 +612,18 @@ MachMgr::GetCurrAxisHomePos( int nInd, double& dHome) const return ( ( pMch != nullptr) ? pMch->GetCurrAxisHomePos( nInd, dHome) : false) ; } +//---------------------------------------------------------------------------- +const Frame3d& +MachMgr::GetCurrLinAxesFrame( void) const +{ + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) { + static Frame3d frDummy ; + return frDummy ; + } + return pMch->GetCurrLinAxesFrame() ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, @@ -682,9 +685,7 @@ bool MachMgr::GetCalcToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - return pMch->GetToolDirFromAngles( vAng, vtDir) ; + return ( ( pMch != nullptr) ? pMch->GetToolDirFromAngles( vAng, vtDir) : false) ; } //---------------------------------------------------------------------------- @@ -692,9 +693,7 @@ bool MachMgr::GetCalcAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - return pMch->GetAuxDirFromAngles( vAng, vtDir) ; + return ( ( pMch != nullptr) ? pMch->GetAuxDirFromAngles( vAng, vtDir) : false) ; } //---------------------------------------------------------------------------- @@ -702,9 +701,7 @@ bool MachMgr::GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return false ; - return pMch->GetPartDirFromAngles( vtPart, vAng, vtDir) ; + return ( ( pMch != nullptr) ? pMch->GetPartDirFromAngles( vtPart, vAng, vtDir) : false) ; } //---------------------------------------------------------------------------- @@ -760,9 +757,7 @@ string MachMgr::GetOutstrokeInfo( bool bMM) const { Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return "" ; - return pMch->GetOutstrokeInfo( bMM) ; + return ( ( pMch != nullptr) ? pMch->GetOutstrokeInfo( bMM) : "") ; } //---------------------------------------------------------------------------- @@ -778,7 +773,5 @@ int MachMgr::GetMachineLook( void) const { Machine* pMch = GetCurrMachine() ; - if ( pMch == nullptr) - return MCH_LOOK_NONE ; - return pMch->GetLook() ; + return ( ( pMch != nullptr) ? pMch->GetLook() : MCH_LOOK_NONE) ; } diff --git a/Machine.cpp b/Machine.cpp index a7ac607..505ff42 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -56,6 +56,7 @@ Machine::Machine( void) m_nHeadLinAxes = 0 ; m_nHeadRotAxes = 0 ; m_nHeadSpecRotAxis = -1 ; + m_frLinAx.Reset( false) ; m_nMachineLook = MCH_LOOK_NONE ; } diff --git a/Machine.h b/Machine.h index c9c5ffe..e26ef43 100644 --- a/Machine.h +++ b/Machine.h @@ -119,6 +119,8 @@ class Machine bool GetCurrAxisMax( int nInd, double& dMax) const ; bool GetCurrAxisHomePos( int nInd, double& dHome) const ; bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ; + const Frame3d& GetCurrLinAxesFrame( void) const + { return m_frLinAx ; } bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ; bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, @@ -293,6 +295,7 @@ class Machine int m_nHeadSpecRotAxis ; // indice eventuale asse rotante speciale di testa prima dei lineari di testa (-1 non esiste) KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli + Frame3d m_frLinAx ; // sistema di riferimento definito dagli assi lineari mutable OutStroke m_OutstrokeInfo ; // informazioni su ultima extra corsa // stato di visualizzazione int m_nMachineLook ; // stato di visualizzazione della macchina diff --git a/MachineCalc.cpp b/MachineCalc.cpp index bf2867a..cd1044c 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -215,7 +215,9 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) // recupero i dati della testa Head* pHead = GetHead( nHeadId) ; if ( pHead == nullptr) { - string sOut = "Missing head " + sHead + " for tool " + sTool ; + string sOutHead = ( IsEmptyOrSpaces( sHead) ? "???" : sHead) ; + string sOutTool = ( IsEmptyOrSpaces( sTool) ? "???" : sTool) ; + string sOut = "Missing head " + sOutHead + " for tool " + sOutTool ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) return false ; } @@ -495,24 +497,28 @@ Machine::CalculateKinematicChain( void) if ( m_vCalcLinAx.size() != 3) return false ; // devono essere ordinabili come XYZ - if ( ! m_vCalcLinAx[0].vtDir.IsXplus()) { - if ( m_vCalcLinAx[1].vtDir.IsXplus()) + if ( ! m_vCalcLinAx[0].vtDir.IsX()) { + if ( m_vCalcLinAx[1].vtDir.IsX()) swap( m_vCalcLinAx[0], m_vCalcLinAx[1]) ; - else if ( m_vCalcLinAx[2].vtDir.IsXplus()) + else if ( m_vCalcLinAx[2].vtDir.IsX()) swap( m_vCalcLinAx[0], m_vCalcLinAx[2]) ; else { - LOG_ERROR( GetEMkLogger(), "Linear Axes not aligned with Global XYZ") + LOG_ERROR( GetEMkLogger(), "Linear Axes are not aligned with Global XYZ") return false ; } } - if ( ! m_vCalcLinAx[1].vtDir.IsYplus()) { - if ( m_vCalcLinAx[2].vtDir.IsYplus()) + if ( ! m_vCalcLinAx[1].vtDir.IsY()) { + if ( m_vCalcLinAx[2].vtDir.IsY()) swap( m_vCalcLinAx[1], m_vCalcLinAx[2]) ; else { - LOG_ERROR( GetEMkLogger(), "Linear Axes not aligned with Global XYZ") + LOG_ERROR( GetEMkLogger(), "Linear Axes are not aligned with Global XYZ") return false ; } } + if ( ! m_frLinAx.Set( ORIG, m_vCalcLinAx[0].vtDir, m_vCalcLinAx[1].vtDir, m_vCalcLinAx[2].vtDir)) { + LOG_ERROR( GetEMkLogger(), "Linear Axes are not a Rigth-handed Frame") + return false ; + } // verifiche sugli assi rotanti : bool bOk = false ; @@ -1143,10 +1149,14 @@ Machine::GetPositions( const Point3d& ptP, const DBLVECTOR& vAng, // calcolo il recupero di lunghezza utensile Vector3d vtDtTL = vtDirH * m_dCalcTLen ; - // calcolo le posizioni degli assi lineari - dX = ptW.x + vtDtHe.x + vtDtAx.x + vtDtTL.x ; - dY = ptW.y + vtDtHe.y + vtDtAx.y + vtDtTL.y ; - dZ = ptW.z + vtDtHe.z + vtDtAx.z + vtDtTL.z ; + // calcolo i valori degli assi lineari (posizioni) + Point3d ptPos( ptW.x + vtDtHe.x + vtDtAx.x + vtDtTL.x, + ptW.y + vtDtHe.y + vtDtAx.y + vtDtTL.y, + ptW.z + vtDtHe.z + vtDtAx.z + vtDtTL.z) ; + ptPos.ToLoc( m_frLinAx) ; + dX = ptPos.x ; + dY = ptPos.y ; + dZ = ptPos.z ; // tutto ok nStat = 0 ; diff --git a/Operation.cpp b/Operation.cpp index 88e7820..ae981e1 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1522,7 +1522,6 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, return false ; // massima variazione secondo asse rotante per continuitą double dDeltaR2Max = 30 ; - // recupero il numero degli assi lineari e rotanti // predispongo variabile per valori assi DBLVECTOR vAxVal ; vAxVal.reserve( 8) ; @@ -1816,9 +1815,10 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, // se realmente arco if ( pCurve->GetType() == CRV_ARC) { ICurveArc* pArc = GetCurveArc( pCurve) ; - // verifico il piano + // verifico il piano (il vettore va portato nel riferimento degli assi lineari) Vector3d vtRef ; m_pMchMgr->GetCalcPartDirFromAngles( pCamData->GetNormDir(), vAngEnd, vtRef) ; + vtRef.ToLoc( m_pMchMgr->GetCurrLinAxesFrame()) ; if ( pArc->GetNormVersor() * vtRef < 0) pArc->InvertN() ; // assegno il centro e il raggio di questo arco ai dati cam