Files
EgtMachKernel/Exit.cpp
T
Dario Sassi 285e0ce910 EgtMachKernel 2.5h2 :
- aggiunta definizione EMC.VER con versione della dll a OnSetTable, OnSetHead e OnVerifyProtectedAreas
- alla modifica di posizione o direzione di un asse si sistema anche la geometria per la simulazione
- alla modifica della posizione di una uscita si sistema anche la geometria per la simulazione
- corretto carico uscite di una testa per direzioni poco discoste da quelle canoniche non correttamente assegnate.
2023-08-19 11:53:38 +02:00

141 lines
4.1 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : Exit.cpp Data : 25.05.15 Versione : 1.6e7
// Contenuto : Oggetto uscita per gruppo uscita di testa di macchina.
//
//
//
// Modifiche : 25.05.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "Exit.h"
#include "MachConst.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( "EMkExit", Exit) ;
//----------------------------------------------------------------------------
const string&
Exit::GetClassName( void) const
{
return USEROBJ_GETNAME( Exit) ;
}
//----------------------------------------------------------------------------
Exit*
Exit::Clone( void) const
{
// alloco oggetto
Exit* pExit = new(nothrow) Exit ;
// eseguo copia dei dati
if ( pExit != nullptr) {
try { pExit->m_nOwnerId = GDB_ID_NULL ;
pExit->m_pGeomDB = nullptr ;
pExit->m_sName = m_sName ;
pExit->m_ptPos = m_ptPos ;
pExit->m_vtTDir = m_vtTDir ;
pExit->m_sTool = m_sTool ;
}
catch( ...) {
delete pExit ;
return nullptr ;
}
}
// ritorno l'oggetto
return pExit ;
}
//----------------------------------------------------------------------------
bool
Exit::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
sOut += GetClassName() + szNewLine ;
sOut += "Id=" + ToString( m_nOwnerId) + szNewLine ;
sOut += "Name=" + m_sName + szNewLine ;
sOut += "Pos=" + ToString( GetInUiUnits( m_ptPos, bMM), 4) + szNewLine ;
sOut += "TDir=" + ToString( m_vtTDir) + szNewLine ;
sOut += "Tool=" + m_sTool + szNewLine ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::SetOwner( int nId, IGeomDB* pGDB)
{
m_nOwnerId = nId ;
m_pGeomDB = pGDB ;
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
}
//----------------------------------------------------------------------------
int
Exit::GetOwner( void) const
{
return m_nOwnerId ;
}
//----------------------------------------------------------------------------
IGeomDB*
Exit::GetGeomDB( void) const
{
return m_pGeomDB ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Exit::Exit( void)
: m_nOwnerId( GDB_ID_NULL), m_pGeomDB( nullptr)
{
}
//----------------------------------------------------------------------------
bool
Exit::Set( const string& sName, const Point3d& ptPos, const Vector3d& vtTDir)
{
m_sName = sName ;
m_ptPos = ptPos ;
m_vtTDir = vtTDir ;
m_sTool.clear() ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::Modify( const Point3d& ptPos, double dExitMaxAdjust)
{
// Verifico che lo spostamento non superi il massimo ammesso
Vector3d vtDelta = ptPos - m_ptPos ;
if ( vtDelta.Len() > dExitMaxAdjust) {
string sOut = " Modify Exit " + m_sName + " Position (" + ToString( ptPos) + ") failed" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
}
// Assegno la nuova posizione
m_ptPos = ptPos ;
// Sistemo la geometria dell'uscita
if ( ! vtDelta.IsZero())
m_pGeomDB->Translate( m_nOwnerId, vtDelta) ;
return true ;
}
//----------------------------------------------------------------------------
bool
Exit::SetTool( const string& sTool)
{
m_sTool = sTool ;
return true ;
}