Files
EgtMachKernel/Milling.cpp
T
Dario Sassi b96b43e1ec EgtMachKernel 1.6f2 :
- aggiunto UserObj CamData per rappresentare dati tipo CL in entità geometriche
- possibilità di ruotare i sottopezzi
- aggiunto calcolo percorsi di lavorazione di fori
- aggiunte prime versioni parziali di taglio con lama e fresatura.
2015-06-16 07:43:02 +00:00

172 lines
5.2 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : Milling.cpp Data : 07.06.15 Versione : 1.6f2
// Contenuto : Implementazione gestione fresature.
//
//
//
// Modifiche : 07.06.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "MachMgr.h"
#include "DllMain.h"
#include "Milling.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
using namespace std ;
//----------------------------------------------------------------------------
static std::string KEY_IDS = "IDS" ;
//----------------------------------------------------------------------------
USEROBJ_REGISTER( "EMkMilling", Milling) ;
//----------------------------------------------------------------------------
const string&
Milling::GetClassName( void) const
{
return USEROBJ_GETNAME( Milling) ;
}
//----------------------------------------------------------------------------
Milling*
Milling::Clone( void) const
{
// alloco oggetto
Milling* pMill = new(nothrow) Milling ;
// eseguo copia dei dati
if ( pMill != nullptr) {
try {
pMill->m_nOwnerId = GDB_ID_NULL ;
pMill->m_pGeomDB = nullptr ;
pMill->m_Params = m_Params ;
pMill->m_TParams = m_TParams ;
}
catch( ...) {
delete pMill ;
return nullptr ;
}
}
// ritorno l'oggetto
return pMill ;
}
//----------------------------------------------------------------------------
bool
Milling::Dump( string& sOut, const char* szNewLine) const
{
sOut += GetClassName() + szNewLine ;
sOut += KEY_IDS + EQUAL + ToString( m_vId) + szNewLine ;
for ( int i = 0 ; i < m_Params.GetSize() ; ++ i)
sOut += m_Params.ToString( i) + szNewLine ;
for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i)
sOut += m_TParams.ToString( i) + szNewLine ;
return true ;
}
//----------------------------------------------------------------------------
bool
Milling::Save( STRVECTOR& vString) const
{
try {
int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ;
vString.insert( vString.begin(), nSize, "") ;
int k = - 1 ;
if ( ! SetVal( KEY_IDS, m_vId, vString[++k]))
return false ;
for ( int i = 0 ; i < m_Params.GetSize() ; ++ i)
vString[++k] = m_Params.ToString( i) ;
for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i)
vString[++k] = m_TParams.ToString( i) ;
}
catch( ...) {
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Milling::Load( const STRVECTOR& vString)
{
int nSize = 1 + m_Params.GetSize() + m_TParams.GetSize() ;
if ( int( vString.size()) < nSize)
return false ;
int k = - 1 ;
if ( ! GetVal( vString[++k], KEY_IDS, m_vId))
return false ;
for ( int i = 0 ; i < m_Params.GetSize() ; ++ i) {
int nKey ;
if ( ! m_Params.FromString( vString[++k], nKey) || nKey != i)
return false ;
}
for ( int i = 0 ; i < m_TParams.GetSize() ; ++ i) {
int nKey ;
if ( ! m_TParams.FromString( vString[++k], nKey) || nKey != i)
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Milling::Milling( void)
{
m_nOwnerId = GDB_ID_NULL ;
m_pGeomDB = nullptr ;
m_Params.m_sName = "*" ;
m_Params.m_sToolName = "*" ;
m_TParams.m_sName = "*" ;
m_TParams.m_sHead = "*" ;
}
//----------------------------------------------------------------------------
bool
Milling::Prepare( const string& sMillName)
{
// verifico il gestore lavorazioni
if ( m_pMchMgr == nullptr)
return false ;
// recupero il gestore DB utensili della macchina corrente
ToolsMgr* pTMgr = m_pMchMgr->GetCurrToolsMgr() ;
if ( pTMgr == nullptr)
return false ;
// recupero il gestore DB lavorazioni della macchina corrente
MachiningsMgr* pMMgr = m_pMchMgr->GetCurrMachiningsMgr() ;
if ( pMMgr == nullptr)
return false ;
// ricerca della lavorazione di libreria con il nome indicato
const MillingData* pDdata = GetMillingData( pMMgr->GetMachining( sMillName)) ;
if ( pDdata == nullptr)
return false ;
m_Params = *pDdata ;
// ricerca dell'utensile usato dalla lavorazione
const ToolData* pTdata = pTMgr->GetTool( m_Params.m_ToolUuid) ;
if ( pTdata == nullptr)
return false ;
m_TParams = *pTdata ;
m_Params.m_sToolName = m_TParams.m_sName ;
return true ;
}
//----------------------------------------------------------------------------
bool
Milling::SetGeometry( const SELVECTOR& vIds)
{
return false ;
}
//----------------------------------------------------------------------------
bool
Milling::Apply( void)
{
return false ;
}