EgtGeomKernel 1.4a5 : Modifiche per EgtGeneral.
This commit is contained in:
+51
-33
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2013-2013
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GdbExecutor.cpp Data : 25.11.13 Versione : 1.3a1
|
||||
// File : GdbExecutor.cpp Data : 25.11.13 Versione : 1.3a5
|
||||
// Contenuto : Implementazione della classe GdbExecutor.
|
||||
//
|
||||
//
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "GdbExecutor.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
@@ -25,8 +25,6 @@
|
||||
#include "/EgtDev/Include/EgkCurveBezier.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "GdbIterator.h"
|
||||
#include "GdbExecutor.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
@@ -40,6 +38,8 @@ CreateGdbExecutor( void)
|
||||
//----------------------------------------------------------------------------
|
||||
GdbExecutor::GdbExecutor( void)
|
||||
{
|
||||
m_pGDB = nullptr ;
|
||||
m_pLogger = nullptr ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -49,22 +49,23 @@ GdbExecutor::~GdbExecutor( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::Set( IGeomDB* pGdb)
|
||||
GdbExecutor::Init( IGeomDB* pGdb, ILogger* pLogger)
|
||||
{
|
||||
m_pGDB = pGdb ;
|
||||
m_pLogger = pLogger ;
|
||||
|
||||
return ( m_pGDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::Load( const wstring& sFile)
|
||||
GdbExecutor::Load( const string& sFile)
|
||||
{
|
||||
bool bOk ;
|
||||
ifstream ifLoad ;
|
||||
|
||||
|
||||
ifLoad.open( sFile) ;
|
||||
ifLoad.open( stringtoW( sFile)) ;
|
||||
if ( ifLoad.good()) {
|
||||
bOk = m_pGDB->Load( ifLoad) ;
|
||||
ifLoad.close() ;
|
||||
@@ -77,13 +78,13 @@ GdbExecutor::Load( const wstring& sFile)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::Save( const wstring& sFile)
|
||||
GdbExecutor::Save( const string& sFile)
|
||||
{
|
||||
bool bOk ;
|
||||
ofstream ofSave ;
|
||||
|
||||
|
||||
ofSave.open( sFile) ;
|
||||
ofSave.open( stringtoW( sFile)) ;
|
||||
if ( ofSave.good()) {
|
||||
bOk = m_pGDB->Save( ofSave) ;
|
||||
ofSave.close() ;
|
||||
@@ -98,18 +99,19 @@ GdbExecutor::Save( const wstring& sFile)
|
||||
bool
|
||||
GdbExecutor::Execute( const string& sCmd1, const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
string sOut ;
|
||||
STRVECTOR::const_iterator theConstIter ;
|
||||
|
||||
|
||||
// output di debug
|
||||
cout << "Cmd = [" << sCmd1 << "/" << sCmd2 << "]" ;
|
||||
cout << " Par = [" ;
|
||||
sOut = "Cmd = [" + sCmd1 + "/" + sCmd2 + "] Par = [" ;
|
||||
for ( theConstIter = vsParams.begin() ; theConstIter != vsParams.end() ; ++theConstIter) {
|
||||
if ( theConstIter != vsParams.begin())
|
||||
cout << "/" ;
|
||||
cout << *theConstIter ;
|
||||
sOut += "/" ;
|
||||
sOut += *theConstIter ;
|
||||
}
|
||||
cout << "]" << endl ;
|
||||
sOut += "]" ;
|
||||
LOG_DEBUG( m_pLogger, sOut.c_str()) ;
|
||||
|
||||
// esecuzione comando
|
||||
if ( sCmd1 == "ALIAS")
|
||||
@@ -244,7 +246,7 @@ GdbExecutor::ExecutePoint( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGPnt == nullptr)
|
||||
return false ;
|
||||
pGPnt->Set( Pnt) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]),pGPnt) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], pGPnt) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -270,7 +272,7 @@ GdbExecutor::ExecuteVector( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGVect == nullptr)
|
||||
return false ;
|
||||
pGVect->Set( Vect) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGVect) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], pGVect) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -300,7 +302,7 @@ GdbExecutor::ExecuteFrame( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
if ( pGFrame == nullptr)
|
||||
return false ;
|
||||
pGFrame->Set( ptOrig, vtDirX, vtDirY, vtDirZ) ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), pGFrame) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], pGFrame) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -325,7 +327,7 @@ GdbExecutor::ExecuteCurveLine( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
PtrOwner<ICurveLine> pCrvLine( CreateCurveLine()) ;
|
||||
if ( ! IsValid( pCrvLine) || ! pCrvLine->Set( ptStart, ptEnd))
|
||||
return false ;
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvLine)) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvLine)) ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
@@ -407,7 +409,7 @@ GdbExecutor::ExecuteCurveArc( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco l'arco nel DB
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvArc)) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvArc)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -467,7 +469,7 @@ GdbExecutor::ExecuteCurveBez( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
|
||||
// inserisco la curva di Bezier nel DB
|
||||
return ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvBez)) != GDB_ID_NULL) ;
|
||||
return AddGeoObj( vsParams[0], vsParams[1], Release( pCrvBez)) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -503,7 +505,7 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
// inserisco la curva composita nel DB
|
||||
if ( m_pGDB->AddGeoObj( GetIdParam( vsParams[0]), GetIdParam( vsParams[1]), Release( pCrvCompo))) {
|
||||
if ( AddGeoObj( vsParams[0], vsParams[1], Release( pCrvCompo))) {
|
||||
// se richiesto, cancello le curve originali
|
||||
if ( bErase) {
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
@@ -520,6 +522,20 @@ GdbExecutor::ExecuteCurveCompo( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::AddGeoObj( const string& sId, const string& sIdParent, IGeoObj* pGeoObj)
|
||||
{
|
||||
// creo il gruppo
|
||||
int nId = GetIdParam( sId) ;
|
||||
int nIdNew = m_pGDB->AddGeoObj( nId, GetIdParam( sIdParent), pGeoObj) ;
|
||||
// se IdDest da calcolare e indicato da Alias, ne cambio il valore
|
||||
if ( nId == GDB_ID_NULL && m_AliasMap.find( sId) != m_AliasMap.end())
|
||||
m_AliasMap[sId] = nIdNew ;
|
||||
|
||||
return ( nIdNew != GDB_ID_NULL) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
int
|
||||
GdbExecutor::GetIdParam( const std::string& sParam)
|
||||
@@ -829,9 +845,9 @@ GdbExecutor::ExecuteLoad( const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// pulizia e reinizializzazione del DB geometrico
|
||||
m_pGDB->Clear() ;
|
||||
m_pGDB->Init() ;
|
||||
m_pGDB->ReInit() ;
|
||||
// esecuzione caricamento
|
||||
return Load( stringtoW( vsParams[0])) ;
|
||||
return Load( vsParams[0]) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -842,20 +858,20 @@ GdbExecutor::ExecuteSave( const STRVECTOR& vsParams)
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// esecuzione salvataggio
|
||||
return Save( stringtoW( vsParams[0])) ;
|
||||
return Save( vsParams[0]) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// apro il file di uscita Scl
|
||||
// apro il file di uscita Scl
|
||||
if ( sCmd2 == "OPEN") {
|
||||
// 1 parametro
|
||||
if ( vsParams.size() != 1)
|
||||
return false ;
|
||||
// apro il file e scrivo intestazione
|
||||
return m_OutScl.Open( stringtoW( vsParams[0])) ;
|
||||
return m_OutScl.Open( vsParams[0]) ;
|
||||
}
|
||||
// chiudo il file di uscita Scl
|
||||
else if ( sCmd2 == "CLOSE") {
|
||||
@@ -899,8 +915,8 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
}
|
||||
// emetto oggetto geometrico
|
||||
else if ( sCmd2 == "PUT") {
|
||||
bool bCrvVsPolyg ;
|
||||
int nId ;
|
||||
int nFlag ;
|
||||
int nId ;
|
||||
STRVECTOR vsNames ;
|
||||
STRVECTOR::iterator Iter ;
|
||||
// almeno un parametro
|
||||
@@ -908,9 +924,9 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
return false ;
|
||||
// se esiste il secondo
|
||||
if ( vsParams.size() == 2)
|
||||
bCrvVsPolyg = ( vsParams[1] != "CPS") ;
|
||||
FromString( vsParams[1], nFlag) ;
|
||||
else
|
||||
bCrvVsPolyg = TRUE ;
|
||||
nFlag = 0 ;
|
||||
// recupero lista nomi
|
||||
if ( ! GetNamesParam( vsParams[0], vsNames))
|
||||
return false ;
|
||||
@@ -918,7 +934,7 @@ GdbExecutor::ExecuteOutScl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
for ( Iter = vsNames.begin() ; Iter != vsNames.end() ; ++Iter) {
|
||||
// recupero l'oggetto ed eseguo l'output
|
||||
nId = GetIdParam( *Iter) ;
|
||||
if ( ! m_OutScl.PutCurve( m_pGDB->GetGeoObj( nId), bCrvVsPolyg))
|
||||
if ( ! m_OutScl.PutCurve( m_pGDB->GetGeoObj( nId), nFlag))
|
||||
return false ;
|
||||
}
|
||||
return true ;
|
||||
@@ -946,13 +962,15 @@ GdbExecutor::OutGroupScl( int nId)
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
// emetto entità gruppo
|
||||
Iter.SetGDB( m_pGDB) ;
|
||||
bNext = Iter.GoToFirstInGroup( nId) ;
|
||||
while ( bNext) {
|
||||
nGdbType = Iter.GetGdbType() ;
|
||||
if ( nGdbType == GDB_GEO) {
|
||||
if ( ! m_OutScl.PutCurve( Iter.GetGeoObj(), true))
|
||||
if ( ! m_OutScl.PutCurve( Iter.GetGeoObj(), 0))
|
||||
return false ;
|
||||
}
|
||||
else if ( nGdbType == GDB_GROUP) {
|
||||
|
||||
Reference in New Issue
Block a user