diff --git a/CamData.cpp b/CamData.cpp index dfce899..1b6ab5c 100644 --- a/CamData.cpp +++ b/CamData.cpp @@ -45,7 +45,9 @@ static std::string CAM_NDIR = "NDir" ; static std::string CAM_AXND = "AxND" ; static int CAM_PARAM_V4 = 19 ; static std::string CAM_NDLT = "NDlt" ; -static int CAM_TOTPARAM =CAM_PARAM_V4 ; +static int CAM_PARAM_V5 = 20 ; +static std::string CAM_BDIR = "BDir" ; +static int CAM_TOTPARAM =CAM_PARAM_V5 ; //---------------------------------------------------------------------------- USEROBJ_REGISTER( "EMkCamData", CamData) ; @@ -87,6 +89,7 @@ CamData::Clone( void) const pCam->m_dMachRad = m_dMachRad ; pCam->m_dMachAngCen = m_dMachAngCen ; pCam->m_vtMachN = m_vtMachN ; + pCam->m_vtBackAux = m_vtBackAux ; } catch( ...) { delete pCam ; @@ -121,6 +124,7 @@ CamData::Dump( string& sOut, bool bMM, const char* szNewLine) const sOut += CAM_AXAC + "=" + ToString( m_dMachAngCen) + szNewLine ; sOut += CAM_AXND + "=" + ToString( m_vtMachN) + szNewLine ; sOut += CAM_NDLT + "=" + ToString( m_dDeltaN) + szNewLine ; + sOut += CAM_BDIR + "=" + ToString( m_vtBackAux) + szNewLine ; return true ; } @@ -177,6 +181,8 @@ CamData::Save( STRVECTOR& vString) const vString[++k] = CAM_AXND + "=" + ToString( m_vtMachN) ; // parametri aggiunti V4 vString[++k] = CAM_NDLT + "=" + ToString( m_dDeltaN) ; + // parametri aggiunti V5 + vString[++k] = CAM_BDIR + "=" + ToString( m_vtBackAux) ; } catch( ...) { return false ; @@ -237,6 +243,14 @@ CamData::Load( const STRVECTOR& vString, int nBaseGdbId) else { m_dDeltaN = 0 ; } + // parametri aggiunti V5 + if ( int( vString.size()) >= CAM_PARAM_V5) { + if ( ! GetVal( vString[++k], CAM_BDIR, m_vtBackAux)) + return false ; + } + else { + m_vtBackAux = V_NULL ; + } return true ; } @@ -656,6 +670,14 @@ CamData::SetAxesNormDir( const Vector3d& vtDir) return true ; } +//---------------------------------------------------------------------------- +bool +CamData::SetBackAuxDir( const Vector3d& vtDir) +{ + m_vtBackAux = vtDir ; + return true ; +} + //---------------------------------------------------------------------------- void CamData::ResetObjGraphics( void) diff --git a/CamData.h b/CamData.h index 629cb59..005a594 100644 --- a/CamData.h +++ b/CamData.h @@ -64,6 +64,7 @@ class CamData : public IUserObj bool SetAxesRad( double dRad) ; bool SetAxesAngCen( double dAngCen) ; bool SetAxesNormDir( const Vector3d& vtDir) ; + bool SetBackAuxDir( const Vector3d& vtDir) ; const int GetMoveType( void) const { return m_nMove ; } const bool IsArc( void) const @@ -102,6 +103,8 @@ class CamData : public IUserObj { return m_dMachAngCen ; } const Vector3d& GetAxesNormDir( void) const { return m_vtMachN ; } + const Vector3d& GetBackAuxDir( void) const + { return m_vtBackAux ; } public : enum { AS_NONE = 0, @@ -142,6 +145,7 @@ class CamData : public IUserObj double m_dMachRad ; // raggio arco espresso in macchina double m_dMachAngCen ; // angolo al centro per archi espresso in macchina Vector3d m_vtMachN ; // vettore normale al piano di giacitura per archi espresso in macchina + Vector3d m_vtBackAux ; // vettore ausiliario di testa ruotato con assi macchina e riportato sul pezzo in lavoro } ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index fb16e29..367176f 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -572,7 +572,10 @@ bool MachMgr::GetCalcToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; - return ( ( pMch != nullptr) ? pMch->GetToolDirFromAngles( dAngA, dAngB, vtDir) : false) ; + if ( pMch == nullptr) + return false ; + DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ; + return pMch->GetToolDirFromAngles( vAng, vtDir) ; } //---------------------------------------------------------------------------- @@ -580,7 +583,10 @@ bool MachMgr::GetCalcAuxDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const { Machine* pMch = GetCurrMachine() ; - return ( ( pMch != nullptr) ? pMch->GetAuxDirFromAngles( dAngA, dAngB, vtDir) : false) ; + if ( pMch == nullptr) + return false ; + DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ; + return pMch->GetAuxDirFromAngles( vAng, vtDir) ; } //---------------------------------------------------------------------------- diff --git a/Machine.cpp b/Machine.cpp index cd5a259..4fd8626 100644 --- a/Machine.cpp +++ b/Machine.cpp @@ -738,6 +738,15 @@ Machine::AdjustExitFrames( int nLay, const MUEXITVECTOR& vMuExit, const Vector3d string sOut = " Exit " + sName + " with frame not adjustable for AuxDir" ; LOG_ERROR( GetEMkLogger(), sOut.c_str()) ; } + // se prima uscita, aggiungo vettore ausiliario + if ( i == 0) { + PtrOwner pGVec( CreateGeoVector3d()) ; + if ( ! IsNull( pGVec) && pGVec->Set( vtAuxL, frFrame.Orig())) { + int nAvId = m_pGeomDB->AddGeoObj( GDB_ID_NULL, nLay, Release( pGVec)) ; + m_pGeomDB->SetName( nAvId, MCH_AUX_VECT) ; + m_pGeomDB->SetStatus( nAvId, GDB_ST_OFF) ; + } + } } } return true ; diff --git a/Machine.h b/Machine.h index 175b2ab..7d1faf7 100644 --- a/Machine.h +++ b/Machine.h @@ -55,6 +55,7 @@ class Machine bool GetAllHeadsNames( STRVECTOR& vNames) const ; bool GetAllTablesNames( STRVECTOR& vNames) const ; int GetHeadExitCount( const std::string& sHead) const ; + int GetHeadExitPosDirAux( const std::string& sHead, int nExit, Point3d& ptPos, Vector3d& vtDir, Vector3d& vtAux) const ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const ; bool UnloadTool( const std::string& sHead, int nExit) ; @@ -113,8 +114,10 @@ class Machine double& dRecX, double& dRecY, double& dRecZ) const ; bool GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng, bool bBottom, bool bOverall, Point3d& ptTip) const ; - bool GetToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const ; - bool GetAuxDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const ; + bool GetToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ; + bool GetAuxDirFromAngles( 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 ; bool LimitAngleToStroke( int nInd, double& dAng) const ; bool VerifyAngleOutstroke( int nInd, double dAng) const ; @@ -205,6 +208,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 GetBackDirection( 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 ; diff --git a/MachineAxes.cpp b/MachineAxes.cpp index f277d07..084ac96 100644 --- a/MachineAxes.cpp +++ b/MachineAxes.cpp @@ -162,7 +162,7 @@ Machine::ResetAxisPos( const string& sAxis) bool Machine::ResetAllAxesPos( void) { - // ciclo sugi gruppi della macchina + // ciclo sui gruppi della macchina for ( auto Iter = m_mapGroups.cbegin() ; Iter != m_mapGroups.cend() ; ++ Iter) { if ( IsAxisGroup( Iter->second)) { if ( ! ResetAxisPos( Iter->first)) diff --git a/MachineCalc.cpp b/MachineCalc.cpp index abf8bfa..e566ac6 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -1012,35 +1012,46 @@ Machine::GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& v { // è espressa nel riferimento di macchina (tiene conto delle sole rotazioni di testa) + // verifico dimensione vettore angoli rispetto al numero di assi rotanti + if ( vAng.size() < m_vCalcRotAx.size()) + return false ; + // direzione a riposo vtNew = vtDir ; - // se c'è terzo asse rotante di testa - if ( m_vCalcRotAx.size() >= 3 && m_vCalcRotAx[2].bHead) { - // posizione e direzione secondo asse rotante - Point3d ptAx3 = m_vCalcRotAx[2].ptPos ; - Vector3d vtAx3 = m_vCalcRotAx[2].vtDir ; - // ruoto dati a riposo - vtNew.Rotate( vtAx3, vAng[2]) ; + // ciclo sugli assi di testa dall'ultimo (prima assi di tavola, poi di testa) + for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) { + // se asse di testa + if ( m_vCalcRotAx[i-1].bHead) + vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; } - // se c'è secondo asse rotante di testa - if ( m_vCalcRotAx.size() >= 2 && m_vCalcRotAx[1].bHead) { - // posizione e direzione secondo asse rotante - Point3d ptAx2 = m_vCalcRotAx[1].ptPos ; - Vector3d vtAx2 = m_vCalcRotAx[1].vtDir ; - // ruoto dati a riposo - vtNew.Rotate( vtAx2, vAng[1]) ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetBackDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const +{ + // è espressa nel riferimento del pezzo (tiene conto delle rotazioni di testa e al contrario di quelle di tavola) + + // verifico dimensione vettore angoli rispetto al numero di assi rotanti + if ( vAng.size() < m_vCalcRotAx.size()) + return false ; + + // direzione a riposo + vtNew = vtDir ; + + // ciclo sugli assi dall'ultimo (prima assi di tavola, poi di testa) + for ( size_t i = m_vCalcRotAx.size() ; i >= 1 ; -- i) { + // se asse di testa + if ( m_vCalcRotAx[i-1].bHead) + vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, vAng[i-1]) ; + // altrimenti di tavola + else + vtNew.Rotate( m_vCalcRotAx[i-1].vtDir, - vAng[i-1]) ; } - // se c'è primo asse rotante di testa - if ( m_vCalcRotAx.size() >= 1 && m_vCalcRotAx[0].bHead) { - // posizione e direzione primo asse rotante - Point3d ptAx1 = m_vCalcRotAx[0].ptPos ; - Vector3d vtAx1 = m_vCalcRotAx[0].vtDir ; - // ruoto dati a riposo - vtNew.Rotate( vtAx1, vAng[0]) ; - } return true ; } @@ -1084,20 +1095,32 @@ Machine::GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& //---------------------------------------------------------------------------- bool -Machine::GetToolDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const +Machine::GetToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const { - DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ; return GetDirection( m_vtCalcDir, vAng, vtDir) ; } //---------------------------------------------------------------------------- bool -Machine::GetAuxDirFromAngles( double dAngA, double dAngB, Vector3d& vtDir) const +Machine::GetAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const { - DBLVECTOR vAng( 2) ; vAng[0] = dAngA ; vAng[1] = dAngB ; return GetDirection( m_vtCalcADir, vAng, vtDir) ; } +//---------------------------------------------------------------------------- +bool +Machine::GetBackToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const +{ + return GetBackDirection( m_vtCalcDir, vAng, vtDir) ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetBackAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const +{ + return GetBackDirection( m_vtCalcADir, vAng, vtDir) ; +} + //---------------------------------------------------------------------------- bool Machine::GetSccDir( int nSolCh, const Vector3d& vtDirA, Vector3d& vtDirScc) const diff --git a/MachineHeads.cpp b/MachineHeads.cpp index e4d7ce0..bdab308 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -47,6 +47,29 @@ Machine::GetHeadExitCount( const string& sHead) const return ( ( pHead != nullptr) ? pHead->GetExitCount() : 0) ; } +//---------------------------------------------------------------------------- +int +Machine::GetHeadExitPosDirAux( const string& sHead, int nExit, Point3d& ptPos, Vector3d& vtDir, Vector3d& vtAux) const +{ + if ( m_pGeomDB == nullptr) + return false ; + // recupero testa + int nHeadId = GetGroup( sHead) ; + Head* pHead = GetHead( nHeadId) ; + if ( pHead == nullptr) + return false ; + // recupero uscita + int nExitId = m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_EXIT + ToString( nExit)) ; + Exit* pExit = GetExit( nExitId) ; + if ( pExit == nullptr) + return false ; + // assegno i dati + ptPos = pExit->GetPos() ; + vtDir = pExit->GetTDir() ; + vtAux = pHead->GetADir() ; + return true ; +} + //---------------------------------------------------------------------------- bool Machine::LoadTool( const string& sHead, int nExit, const string& sTool) diff --git a/MachineStruConst.h b/MachineStruConst.h index 20dc262..0edd5f8 100644 --- a/MachineStruConst.h +++ b/MachineStruConst.h @@ -81,6 +81,8 @@ const std::string MCH_TREF = "R" ; const std::string MCH_TAREA ="A" ; //---------------------------------------------------------------------------- +// Identificativo vettore ausiliario di testa +const std::string MCH_AUX_VECT = "AV" ; // Identificativo iniziale gruppo uscita di teste const std::string MCH_EXIT = "T" ; diff --git a/Machining.cpp b/Machining.cpp index 7487552..97d3fb5 100644 --- a/Machining.cpp +++ b/Machining.cpp @@ -121,7 +121,10 @@ bool Machining::ShowTool( int nPath, double dFraz) const { // verifico validità gestore DB geometrico - if ( m_pGeomDB == nullptr) + if ( m_pGeomDB == nullptr || m_pMchMgr == nullptr) + return false ; + Machine* pMch = m_pMchMgr->GetCurrMachine() ; + if ( pMch == nullptr) return false ; // recupero gruppo per geometria di lavorazione (Cutter Location) int nClId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_CL) ; @@ -131,12 +134,16 @@ Machining::ShowTool( int nPath, double dFraz) const int nEntId = m_pGeomDB->GetFirstInGroup( m_pGeomDB->GetFirstGroupInGroup( nClId)) ; if ( nEntId == GDB_ID_NULL) return false ; + string sName ; m_pGeomDB->GetName( nEntId, sName) ; + if ( sName == MCH_CL_CLIMB) + nEntId = m_pGeomDB->GetNext( nEntId) ; // recupero i dati di questa entità const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( nEntId)) ; if ( pCamData == nullptr) return false ; Point3d ptEnd = pCamData->GetEndPoint() ; Vector3d vtTool = pCamData->GetToolDir() ; + Vector3d vtBAux = pCamData->GetBackAuxDir() ; // creo o svuoto gruppo per anteprima utensile int nStId = m_pGeomDB->GetFirstNameInGroup( GetOwner(), MCH_ST) ; // se non c'è, lo aggiungo @@ -154,6 +161,32 @@ Machining::ShowTool( int nPath, double dFraz) const int nHeadId = m_pMchMgr->GetHeadId( GetHeadName()) ; int nId = m_pGeomDB->CopyGlob( nHeadId, GDB_ID_NULL, nStId) ; m_pGeomDB->SetStatus( nId, GDB_ST_ON) ; + // dati correnti testa/uscita + int nExitId = m_pGeomDB->GetFirstNameInGroup( nId, MCH_EXIT + ToString( GetExitNbr())) ; + Frame3d frExit ; + m_pGeomDB->GetGroupGlobFrame( nExitId, frExit) ; + Point3d ptOrig = frExit.Orig() ; + Vector3d vtDir = frExit.VersZ() ; + Vector3d vtAux ; + int nAvId = m_pGeomDB->GetFirstNameInGroup( nId, MCH_AUX_VECT) ; + ExeStartVector( nAvId, GDB_ID_ROOT, vtAux) ; + // rototraslo opportunamente + Frame3d frHead ; + m_pGeomDB->GetGroupGlobFrame( nId, frHead) ; + Frame3d frRef ; + if ( vtAux.IsSmall()) + frRef.Set( ptOrig, vtDir) ; + else + frRef.Set( ptOrig, vtDir, vtAux) ; + Frame3d frShow ; + if ( vtBAux.IsSmall()) + frShow.Set( ptEnd + vtTool * GetToolData().m_dLen, vtTool) ; + else + frShow.Set( ptEnd + vtTool * GetToolData().m_dLen, vtTool, vtBAux) ; + frHead.ToLoc( frRef) ; + frHead.ToGlob( frShow) ; + *(m_pGeomDB->GetGroupFrame( nId)) = frHead ; + return true ; } diff --git a/Milling.cpp b/Milling.cpp index cbbee8e..c044f65 100644 --- a/Milling.cpp +++ b/Milling.cpp @@ -548,13 +548,16 @@ Milling::Apply( bool bRecalc) nPathId = m_pGeomDB->GetNextGroup( nPathId) ; } + // eseguo aggiornamento assi macchina e collegamento con operazione precedente + if ( ! Update()) + return false ; + //// imposto l'utensile per l'anteprima !!! provvisorio per test !!! // if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) // return false ; // ShowTool( 0, 0) ; - // eseguo aggiornamento assi macchina e collegamento con operazione precedente - return Update() ; + return true ; } //---------------------------------------------------------------------------- diff --git a/Operation.cpp b/Operation.cpp index a73b277..09533e1 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -919,6 +919,10 @@ Operation::CalculateClPathAxesValues( int nClPathId, int nLinAxes, int nRotAxes, } // salvo i valori degli assi pCamData->SetAxes( CamData::AS_OK, vAxVal) ; + // calcolo e salvo il valore dell'asse ausiliario di testa riportato sul grezzo + Vector3d vtBackAux ; + m_pMchMgr->GetCurrMachine()->GetBackAuxDirFromAngles( vAng1, vtBackAux) ; + pCamData->SetBackAuxDir( vtBackAux) ; // se arco devo calcolarne il centro in assi macchina if ( pCamData->IsArc()) { // devo lavorare con arco schiacciato nel suo piano diff --git a/OutputConst.h b/OutputConst.h index 58fd163..5fc677c 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -163,8 +163,6 @@ static const std::string ON_SIMUL_MOVE_START = "OnSimulMoveStart" ; static const std::string ON_SIMUL_MOVE_END = "OnSimulMoveEnd" ; // Funzioni macchina static const std::string ON_RESET_MACHINE = "OnResetMachine" ; -// Valore minimo flag per chiamata funzione di movimento in simulazione -static const int MIN_CALL_SIMUL_MOVE = 1000 ; //---------------------------------------------------------------------------- diff --git a/Pocketing.cpp b/Pocketing.cpp index 1ff4c4f..b452822 100644 --- a/Pocketing.cpp +++ b/Pocketing.cpp @@ -525,7 +525,15 @@ Pocketing::Apply( bool bRecalc) return false ; // eseguo aggiornamento assi macchina e collegamento con operazione precedente - return Update() ; + if ( ! Update()) + return false ; + + //// imposto l'utensile per l'anteprima !!! provvisorio per test !!! + // if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) + // return false ; + // ShowTool( 0, 0) ; + + return true ; } //----------------------------------------------------------------------------