Files
EgtExchange/ExcExecutor.cpp
T
Dario Sassi fca2574f79 EgtExchange 1.5e3 :
- aggiunto fattore di scalatura a ImportStl
- uso di PointGrid3d in import STL invece di ordinamento lessicografico.
2014-05-18 09:30:03 +00:00

142 lines
4.3 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : ExcExecutor.cpp Data : 04.04.14 Versione : 1.5d1
// Contenuto : Implementazione della classe ExcExecutor.
//
//
//
// Modifiche : 04.04.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "ExcExecutor.h"
#include "DllMain.h"
#include "/EgtDev/Include/EgnStringUtils.h"
#include "/EgtDev/Include/EgnCmdParser.h"
#include "/EgtDev/Include/EExImportStl.h"
#include "/EgtDev/Include/EExImportDxf.h"
using namespace std ;
//----------------------------------------------------------------------------
IExcExecutor*
CreateExcExecutor( void)
{
return static_cast<IExcExecutor*> ( new ExcExecutor) ;
}
//----------------------------------------------------------------------------
ExcExecutor::ExcExecutor( void)
{
// assegno chiavi a funzioni di esecuzione
m_ExecMgr.Init( 4) ;
m_ExecMgr.Insert( "IMPORTSTL", &ExcExecutor::ExecuteImportStl) ;
m_ExecMgr.Insert( "IMPORTDXF", &ExcExecutor::ExecuteImportDxf) ;
}
//----------------------------------------------------------------------------
ExcExecutor::~ExcExecutor( void)
{
}
//----------------------------------------------------------------------------
bool
ExcExecutor::SetCmdParser( ICmdParser* pParser)
{
m_pParser = pParser ;
return ( m_pParser != nullptr) ;
}
//----------------------------------------------------------------------------
int
ExcExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
{
// verifico validita GeomDB
if ( m_pGDB == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : null GeomDb in ExcExecutor.")
return ER_ERR ;
}
// verifico validità CmdParser
if ( m_pParser == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : null CmdParser in ExcExecutor.")
return ER_ERR ;
}
// esecuzione comando
return m_ExecMgr.Execute( *this, sCmd1, sCmd2, vsParams) ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::SetGeomDB( IGeomDB* pGdb)
{
m_pGDB = pGdb ;
return ( m_pGDB != nullptr) ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::ExecuteImportStl( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 o 3 parametri : nome del file, Id del gruppo[, ScaleFactor]
if ( vsParams.size() != 2 && vsParams.size() != 3)
return false ;
// eventuale conversione di token nel nome file
string sFile = vsParams[0] ;
m_pParser->DirReplace( sFile) ;
// recupero l'Id
int nId = m_pParser->GetIdParam( vsParams[1]) ;
if ( nId == CMD_ID_ERROR)
return false ;
// gestisco ScaleFactor
double dScaleFactor = 1 ;
if ( vsParams.size() >= 3)
FromString( vsParams[2], dScaleFactor) ;
// preparo l'importatore
IImportStl* pImpStl = CreateImportStl() ;
if ( pImpStl == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : CreateImportStl")
return false ;
}
// eseguo l'importazione
bool bOk = pImpStl->Import( sFile, m_pGDB, nId, dScaleFactor) ;
// cancello l'importatore
delete pImpStl ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
ExcExecutor::ExecuteImportDxf( const string& sCmd2, const STRVECTOR& vsParams)
{
// 2 parametri : nome del file e Id del gruppo
if ( vsParams.size() != 2)
return false ;
// eventuale conversione di token nel nome file
string sFile = vsParams[0] ;
m_pParser->DirReplace( sFile) ;
// recupero l'Id
int nId = m_pParser->GetIdParam( vsParams[1]) ;
if ( nId == CMD_ID_ERROR)
return false ;
// preparo l'importatore
IImportDxf* pImpDxf = CreateImportDxf() ;
if ( pImpDxf == nullptr) {
LOG_ERROR( GetEExLogger(), "Error : CreateImportDxf")
return false ;
}
// eseguo l'importazione
bool bOk = pImpDxf->Import( sFile, m_pGDB, nId) ;
// cancello l'importatore
delete pImpDxf ;
return bOk ;
}