//---------------------------------------------------------------------------- // EgalTech 2015-2021 //---------------------------------------------------------------------------- // File : Head.cpp Data : 14.10.21 Versione : 2.3j5 // Contenuto : Oggetto testa per gruppo testa di macchina. // // // // Modifiche : 25.05.15 DS Creazione modulo. // 11.01.17 DS Aggiunto contatore uscite. // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "Head.h" #include "MachConst.h" #include "/EgtDev/Include/EMkMachiningConst.h" #include "/EgtDev/Include/EGkGdbConst.h" #include "/EgtDev/Include/EGkUserObjFactory.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGkUiUnits.h" using namespace std ; //---------------------------------------------------------------------------- USEROBJ_REGISTER( "EMkHead", Head) ; //---------------------------------------------------------------------------- const string& Head::GetClassName( void) const { return USEROBJ_GETNAME( Head) ; } //---------------------------------------------------------------------------- Head* Head::Clone( void) const { // alloco oggetto Head* pHead = new(nothrow) Head ; // eseguo copia dei dati if ( pHead != nullptr) { try { pHead->m_nOwnerId = GDB_ID_NULL ; pHead->m_pGeomDB = nullptr ; pHead->m_sName = m_sName ; pHead->m_nType = m_nType ; pHead->m_nExitCount = m_nExitCount ; pHead->m_vsHSet = m_vsHSet ; pHead->m_vtADir = m_vtADir ; pHead->m_dRot1W = m_dRot1W ; pHead->m_bMaxDeltaR2On1 = m_bMaxDeltaR2On1 ; pHead->m_Rot2Stroke = m_Rot2Stroke ; pHead->m_nSolCh = m_nSolCh ; pHead->m_vsOtherColl = m_vsOtherColl ; } catch( ...) { delete pHead ; return nullptr ; } } // ritorno l'oggetto return pHead ; } //---------------------------------------------------------------------------- bool Head::Dump( string& sOut, bool bMM, const char* szNewLine) const { sOut += GetClassName() + szNewLine ; sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ; sOut += "Name=" + m_sName + szNewLine ; sOut += "Type=" + ToString( m_nType) + szNewLine ; sOut += "ExitCount=" + ToString( m_nExitCount) + szNewLine ; sOut += "HSet=" + ToString( m_vsHSet) + szNewLine ; sOut += "ADir=" + ToString( m_vtADir) + szNewLine ; sOut += "OtherColl=" + ToString( m_vsOtherColl) + szNewLine ; return true ; } //---------------------------------------------------------------------------- bool Head::SetOwner( int nId, IGeomDB* pGDB) { m_nOwnerId = nId ; m_pGeomDB = pGDB ; return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ; } //---------------------------------------------------------------------------- int Head::GetOwner( void) const { return m_nOwnerId ; } //---------------------------------------------------------------------------- IGeomDB* Head::GetGeomDB( void) const { return m_pGeomDB ; } //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- Head::Head( void) : m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr), m_nType( MCH_HT_NONE), m_nExitCount( 0), m_nSelectType( MCH_SLT_FIXEDEXITS), m_dRot1W( 1), m_bMaxDeltaR2On1( true), m_nSolCh( MCH_SCC_NONE) { m_Rot2Stroke.Min = - INFINITO ; m_Rot2Stroke.Max = INFINITO ; } //---------------------------------------------------------------------------- bool Head::Set( const string& sName, int nType, int nExitCount, const string& sHSet, int nSelectType, const Vector3d& vtADir, double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl) { m_sName = sName ; m_nType = nType ; if ( m_nType == MCH_HT_MULTI) m_nExitCount = nExitCount ; else m_nExitCount = 1 ; m_vsHSet.clear() ; m_vsHSet.push_back( sHSet) ; if ( nSelectType == MCH_SLT_FIXEDEXITS || nSelectType == MCH_SLT_ONEEXIT || nSelectType == MCH_SLT_MULTIEXITS) m_nSelectType = nSelectType ; else m_nSelectType = MCH_SLT_FIXEDEXITS ; m_vtADir = vtADir ; m_vtADir.Normalize() ; m_dRot1W = dRot1W ; m_bMaxDeltaR2On1 = bMaxDeltaR2On1 ; m_Rot2Stroke = Rot2Stroke ; if ( IsValidHeadScc( nSolCh)) m_nSolCh = nSolCh ; else m_nSolCh = MCH_SCC_NONE ; m_vsOtherColl = vsOthColl ; return true ; } //---------------------------------------------------------------------------- bool Head::AddHeadToHSet( const string& sHead) { // se gią presente non devo fare alcunchč, altrimenti lo aggiungo if ( find( m_vsHSet.begin(), m_vsHSet.end(), sHead) != m_vsHSet.end()) return true ; m_vsHSet.emplace_back( sHead) ; return true ; } //---------------------------------------------------------------------------- bool Head::ModifyHeadAuxDirection( const Vector3d& vtADir) { m_vtADir = vtADir ; m_vtADir.Normalize() ; return true ; }