diff --git a/GeoCalc.cpp b/GeoCalc.cpp index bfb6a12..4e23a58 100644 --- a/GeoCalc.cpp +++ b/GeoCalc.cpp @@ -94,7 +94,7 @@ GetRotationComponent( const Vector3d& vtDir1, double dComp, const Vector3d& vtDi if ( dDenom * dNumer > 0) dAng1Deg = dOffsAngRad * RADTODEG ; else - dAng1Deg = dOffsAngRad * RADTODEG + ANG_STRAIGHT ; + dAng1Deg = dOffsAngRad * RADTODEG + ( dOffsAngRad < 0 ? ANG_STRAIGHT : - ANG_STRAIGHT) ; bDet = true ; return 1 ; } diff --git a/Machine.h b/Machine.h index 2a86826..af2b356 100644 --- a/Machine.h +++ b/Machine.h @@ -187,6 +187,7 @@ class Machine int nNumRotAx, const KinAxis& RotAx1, const KinAxis& RotAx2, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ; bool GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const ; + bool GetSccDir( int nSolCh, const Vector3d& vtDirA, Vector3d& vtDirScc) const ; bool VerifyScc( const Vector3d& vtDirI, const Vector3d& vtDirA, int nSolCh) const ; bool AdjustAngleInStroke( const STROKE& Stroke, double& dAng) const ; bool LuaInit( const std::string& sMachineName) ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index 6b65e5b..c074c7e 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -754,9 +754,11 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, // se indeterminato, provo a determinarlo con la direzione ausiliaria if ( ! bDet2) { bool bDetX ; - vtDirI2.GetRotation( vtDirAn, vtAx1, dAngA2, bDetX) ; + Vector3d vtSccDir ; + bool bSccDir = GetSccDir( m_nCalcSolCh, vtDirAn, vtSccDir) ; + vtDirI2.GetRotation( vtSccDir, vtAx1, dAngA2, bDetX) ; if ( bDetX) - bDet2 = true ; + bDet2 = bSccDir ; else dAngA2 = 0 ; } @@ -775,9 +777,11 @@ Machine::GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, // se indeterminato, provo a determinarlo con la direzione ausiliaria if ( ! bDet1) { bool bDetX ; - vtDirI1.GetRotation( vtDirAn, vtAx1, dAngA1, bDetX) ; + Vector3d vtSccDir ; + bool bSccDir = GetSccDir( m_nCalcSolCh, vtDirAn, vtSccDir) ; + vtDirI1.GetRotation( vtSccDir, vtAx1, dAngA1, bDetX) ; if ( bDetX) - bDet1 = true ; + bDet1 = bSccDir ; else dAngA1 = 0 ; } @@ -1012,6 +1016,24 @@ Machine::GetToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) cons return GetDirection( m_vtCalcDir, vAng, vtDir) ; } +//---------------------------------------------------------------------------- +bool +Machine::GetSccDir( int nSolCh, const Vector3d& vtDirA, Vector3d& vtDirScc) const +{ + switch ( nSolCh) { + case MCH_SCC_ADIR_XP : vtDirScc = X_AX ; return true ; + case MCH_SCC_ADIR_XM : vtDirScc = - X_AX ; return true ; + case MCH_SCC_ADIR_YP : vtDirScc = Y_AX ; return true ; + case MCH_SCC_ADIR_YM : vtDirScc = - Y_AX ; return true ; + case MCH_SCC_ADIR_ZP : vtDirScc = Z_AX ; return true ; + case MCH_SCC_ADIR_ZM : vtDirScc = - Z_AX ; return true ; + case MCH_SCC_ADIR_NEAR : vtDirScc = vtDirA ; return true ; + case MCH_SCC_ADIR_FAR : vtDirScc = - vtDirA ; return true ; + } + vtDirScc = vtDirA ; + return false ; +} + //---------------------------------------------------------------------------- bool Machine::VerifyScc( const Vector3d& vtDirI, const Vector3d& vtDirA, int nSolCh) const diff --git a/Operation.cpp b/Operation.cpp index 2852c42..ef2edea 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -509,8 +509,6 @@ Operation::CalculateAxesValues( const string& sHint) DBLVECTOR vAxRotPrec( nRotAxes, 0.) ; DBLVECTOR vAxVal ; // se utensile non cambiato, uso gli angoli finali della lavorazione precedente - // ! ToolChangeNeeded( *pPrevOp, *this) - // GetToolName() == sPrevTool if ( ! sPrevTool.empty() && ! ToolChangeNeeded( *pPrevOp, *this) && pPrevOp->GetFinalAxesValues( vAxVal)) { for ( int i = 0 ; i < nRotAxes ; ++ i)