diff --git a/MachMgr.h b/MachMgr.h index 4f14980..70e492b 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -421,6 +421,7 @@ class MachMgr : public IMachMgr bool IsKinematicRotAxisBlocked( int nInd) const ; int GetCalcTool( void) const ; double GetCalcRot1W( void) const ; + bool GetCalcPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool SetCalcSolCh( int nScc, bool bExact) ; bool VerifyAngleOutstroke( int nInd, double dAng) const ; bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, bool bClear, int& nStat) const ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index 9ef0f5b..e2a3e37 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -651,6 +651,16 @@ MachMgr::GetCalcAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const return pMch->GetAuxDirFromAngles( vAng, vtDir) ; } +//---------------------------------------------------------------------------- +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) ; +} + //---------------------------------------------------------------------------- bool MachMgr::GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const diff --git a/Machine.h b/Machine.h index 38528c4..93183e7 100644 --- a/Machine.h +++ b/Machine.h @@ -131,6 +131,7 @@ class Machine bool bBottom, bool bOverall, Point3d& ptTip) const ; bool GetToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool GetAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ; + bool GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool GetBackToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool GetBackAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ; bool GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index e9de76c..a997a43 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -1191,6 +1191,29 @@ Machine::GetAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const return GetDirection( m_vtCalcADir, vAng, vtDir) ; } +//---------------------------------------------------------------------------- +bool +Machine::GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const +{ + // è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di tavola) + + // verifico dimensione vettore angoli rispetto al numero di assi rotanti + if ( vAng.size() < m_vCalcRotAx.size()) + return false ; + + // direzione a riposo + vtDir = vtPart ; + + // ciclo sugli assi dal primo (solo assi di tavola) + for ( size_t i = 1 ; i <= m_vCalcRotAx.size() ; ++ i) { + // se asse di tavola + if ( ! m_vCalcRotAx[i-1].bHead) + vtDir.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; + } + + return true ; +} + //---------------------------------------------------------------------------- bool Machine::GetBackToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const diff --git a/Operation.cpp b/Operation.cpp index 7d386a9..caca693 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -1510,7 +1510,9 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, if ( pCurve->GetType() == CRV_ARC) { ICurveArc* pArc = GetCurveArc( pCurve) ; // verifico il piano - if ( pArc->GetNormVersor() * pCamData->GetNormDir() < 0) + Vector3d vtRef ; + m_pMchMgr->GetCalcPartDirFromAngles( pCamData->GetNormDir(), vAngEnd, vtRef) ; + if ( pArc->GetNormVersor() * vtRef < 0) pArc->InvertN() ; // assegno il centro e il raggio di questo arco ai dati cam pCamData->SetAxesCen( pArc->GetCenter()) ;