diff --git a/EExDllMain.cpp b/EExDllMain.cpp
index 17af7dc..fa600d3 100644
--- a/EExDllMain.cpp
+++ b/EExDllMain.cpp
@@ -57,7 +57,7 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
//-----------------------------------------------------------------------------
const char*
-GetEGrVersion( void)
+GetEExVersion( void)
{
std::string sVer ;
diff --git a/EgtExchange.vcxproj b/EgtExchange.vcxproj
index efa1ad6..3cde2de 100644
--- a/EgtExchange.vcxproj
+++ b/EgtExchange.vcxproj
@@ -181,7 +181,10 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
+
@@ -200,6 +203,8 @@ copy $(TargetPath) \EgtProg\Dll64
+
+
Create
Create
diff --git a/EgtExchange.vcxproj.filters b/EgtExchange.vcxproj.filters
index 3914b84..4b66dc8 100644
--- a/EgtExchange.vcxproj.filters
+++ b/EgtExchange.vcxproj.filters
@@ -24,6 +24,15 @@
File di intestazione
+
+ File di intestazione
+
+
+ File di intestazione
+
+
+ File di intestazione
+
@@ -32,6 +41,12 @@
File di origine
+
+ File di origine
+
+
+ File di origine
+
diff --git a/ExcExecutor.cpp b/ExcExecutor.cpp
new file mode 100644
index 0000000..de772dd
--- /dev/null
+++ b/ExcExecutor.cpp
@@ -0,0 +1,96 @@
+//----------------------------------------------------------------------------
+// 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/EExImportStl.h"
+
+using namespace std ;
+
+
+//----------------------------------------------------------------------------
+IExcExecutor*
+CreateExcExecutor( void)
+{
+ return static_cast ( new ExcExecutor) ;
+}
+
+//----------------------------------------------------------------------------
+ExcExecutor::ExcExecutor( void)
+{
+ // assegno chiavi a funzioni di esecuzione
+ m_ExecMgr.Init( 4) ;
+ m_ExecMgr.Insert( "IMPORTSTL", &ExcExecutor::ExecuteImportStl) ;
+}
+
+//----------------------------------------------------------------------------
+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)
+{
+ // 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 parametri : nome del file e Id del gruppo
+ if ( vsParams.size() != 2)
+ return false ;
+
+ // recupero l'Id
+ int nId ;
+ if ( ! FromString( vsParams[1], nId))
+ return false ;
+
+ // preparo l'importatore
+ IImportStl* pImpStl = CreateImportStl() ;
+ if ( pImpStl == nullptr) {
+ LOG_ERROR( GetEExLogger(), "Error : CreateImportStl")
+ return false ;
+ }
+
+ // eseguo l'importazione
+ if ( ! pImpStl->Import( vsParams[0], m_pGDB, nId))
+ return false ;
+
+ // cancello l'importatore
+ delete pImpStl ;
+
+ return true ;
+}
diff --git a/ExcExecutor.h b/ExcExecutor.h
new file mode 100644
index 0000000..f17a9d3
--- /dev/null
+++ b/ExcExecutor.h
@@ -0,0 +1,44 @@
+//----------------------------------------------------------------------------
+// EgalTech 2013-2013
+//----------------------------------------------------------------------------
+// File : GraExecutor.h Data : 18.02.14 Versione : 1.5b3
+// Contenuto : Dichiarazione della classe GraExecutor.
+//
+//
+//
+// Modifiche : 18.02.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+
+#include "/EgtDev/Include/EExExcExecutor.h"
+#include "/EgtDev/Include/EgtExecMgr.h"
+
+
+//----------------------------------------------------------------------------
+class ExcExecutor : public IExcExecutor
+{
+ public : // ICmdExecutor
+ virtual bool SetCmdParser( ICmdParser* pParser) ;
+ virtual bool AddStandardVariables( void)
+ { return true ; }
+ virtual int Execute( const std::string& sCmd1, const std::string& sCmd2, const STRVECTOR& vsParams) ;
+
+ public : // IExcExecutor
+ ~ExcExecutor( void) ;
+ virtual bool SetGeomDB( IGeomDB* pGdb) ;
+
+ public :
+ ExcExecutor( void) ;
+
+ private :
+ bool ExecuteImportStl( const std::string& sCmd2, const STRVECTOR& vsParams) ;
+
+ private :
+ IGeomDB* m_pGDB ;
+ ICmdParser* m_pParser ;
+ ExecManager m_ExecMgr ;
+} ;
diff --git a/ImportStl.cpp b/ImportStl.cpp
new file mode 100644
index 0000000..3dfb606
--- /dev/null
+++ b/ImportStl.cpp
@@ -0,0 +1,236 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ImportStl.cpp Data : 04.04.14 Versione : 1.5d1
+// Contenuto : Implementazione della classe per l'importazione di STL.
+//
+//
+//
+// Modifiche : 04.04.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+//--------------------------- Include ----------------------------------------
+#include "stdafx.h"
+#include "ImportStl.h"
+#include "DllMain.h"
+#include "/EgtDev/Include/EgtPointerOwner.h"
+#include "/EgtDEv/Include/EGnScan.h"
+#include "/EgtDev/Include/EgnStringUtils.h"
+#include "/EgtDev/Include/EGkGeomDB.h"
+#include "/EgtDev/Include/EGkSurfTriMesh.h"
+
+using namespace std ;
+
+//----------------------------------------------------------------------------
+IImportStl*
+CreateImportStl( void)
+{
+ return static_cast ( new(nothrow) ImportStl) ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ImportStl::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup)
+{
+ // inizializzo lo scanner
+ Scanner TheScanner ;
+ if ( ! TheScanner.Init( sFile)) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error on Init")
+ return false ;
+ }
+
+ // verifico il DB geometrico
+ if ( pGDB == nullptr) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error on GeomDB")
+ return false ;
+ }
+ m_pGDB = pGDB ;
+
+ // verifico l'Id di gruppo
+ if ( ! m_pGDB->ExistsObj( nIdGroup)) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error on IdGroup")
+ return false ;
+ }
+ m_nIdGroup = nIdGroup ;
+
+ // ciclo di lettura degli oggetti
+ bool bOk = true ;
+ bool bEnd = false ;
+ do {
+ if ( ! LoadSolid( TheScanner, bEnd)) {
+ bOk = false ;
+ string sOut = "ImportStl : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
+ LOG_ERROR( GetEExLogger(), sOut.c_str())
+ }
+ } while ( bOk && ! bEnd) ;
+
+ return bOk ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ImportStl::LoadSolid( Scanner& TheScanner, bool& bEnd)
+{
+ string sLine ;
+ STRVECTOR vsParams ;
+
+ // recupero la prima linea
+ if ( ! TheScanner.GetLine( sLine)) {
+ bEnd = true ;
+ return true ;
+ }
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 1 parametro
+ if ( vsParams.size() < 1)
+ return false ;
+ // deve essere la parola chiave "solid"
+ if ( vsParams[0] != "solid")
+ return false ;
+ // se c'è un secondo parametro è il nome
+ string sName ;
+ if ( vsParams.size() >= 2)
+ sName = vsParams[1] ;
+
+ // preparo l'oggetto TriMesh
+ PtrOwner pSTM( CreateSurfTriMesh()) ;
+ if ( ! IsValid( pSTM)) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error allocating SurfTriMesh")
+ return false ;
+ }
+ if ( ! pSTM->Init( 3, 1)) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error initialising SurfTriMesh")
+ return false ;
+ }
+
+ // ciclo di lettura dei triangoli
+ bool bOk = true ;
+ bool bTEnd = false ;
+ do {
+ if ( ! LoadTriangle( TheScanner, Get( pSTM), bTEnd)) {
+ bOk = false ;
+ string sOut = "ImportStl : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
+ LOG_ERROR( GetEExLogger(), sOut.c_str())
+ }
+ } while ( bOk && ! bTEnd) ;
+
+ // recupero la linea di terminazione dell'oggetto
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 1 parametro
+ if ( vsParams.size() < 1)
+ return false ;
+ // deve essere la parola chiave "endsolid" oppure "end" "solid"
+ if ( vsParams[0] != "endsolid" && vsParams[0] != "end")
+ return false ;
+
+ // valido la superficie e calcolo le adiacenze
+ if ( ! pSTM->AdjustTopology()) {
+ LOG_ERROR( GetEExLogger(), "ImportStl : Error adjusting topology in SurfTriMesh")
+ return false ;
+ }
+ // inserisco l'oggetto nel DB geometrico
+ int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ;
+ // se previsto il nome, lo assegno
+ if ( ! sName.empty())
+ m_pGDB->SetName( nIdNew, sName) ;
+
+ bEnd = false ;
+ return true ;
+}
+
+//----------------------------------------------------------------------------
+bool
+ImportStl::LoadTriangle( Scanner& TheScanner, ISurfTriMesh* pSTM, bool& bEnd)
+{
+ string sLine ;
+ STRVECTOR vsParams ;
+
+ // recupero la prima linea
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 1 parametro
+ if ( vsParams.size() < 1)
+ return false ;
+ // deve essere la parola chiave "facet"
+ if ( vsParams[0] != "facet") {
+ TheScanner.UngetLine( sLine) ;
+ bEnd = true ;
+ return true ;
+ }
+ // ignoro il resto
+
+ // recupero la seconda linea
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 2 parametri
+ if ( vsParams.size() < 2)
+ return false ;
+ // devono essere le parole chiave "outer" e "loop"
+ if ( vsParams[0] != "outer" || vsParams[1] != "loop")
+ return false ;
+
+ // ciclo sui tre vertici
+ int nIdV[3] ;
+ for ( int i = 0 ; i < 3 ; ++ i) {
+ // recupero una linea
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 4 parametri
+ if ( vsParams.size() < 4)
+ return false ;
+ // parola chiave "vertex"
+ if ( vsParams[0] != "vertex")
+ return false ;
+ // tre coordinate del vertice
+ Point3d ptP ;
+ if ( ! FromString( vsParams[1], ptP.x) ||
+ ! FromString( vsParams[2], ptP.y) ||
+ ! FromString( vsParams[3], ptP.z))
+ return false ;
+ // aggiungo il vertice
+ if ( ( nIdV[i] = pSTM->AddVertex( ptP)) == -1)
+ return false ;
+ }
+
+ // inserisco il triangolo
+ if( pSTM->AddTriangle( nIdV) == -1)
+ return false ;
+
+ // nuova linea
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 1 parametro
+ if ( vsParams.size() < 1)
+ return false ;
+ // parola chiave "endloop"
+ if ( vsParams[0] != "endloop")
+ return false ;
+
+ // nuova linea
+ if ( ! TheScanner.GetLine( sLine))
+ return false ;
+ // la divido in parametri
+ Tokenize( sLine, " ", vsParams) ;
+ // almeno 1 parametro
+ if ( vsParams.size() < 1)
+ return false ;
+ // parola chiave "endfacet"
+ if ( vsParams[0] != "endfacet")
+ return false ;
+
+ bEnd = false ;
+ return true ;
+}
diff --git a/ImportStl.h b/ImportStl.h
new file mode 100644
index 0000000..f48f92d
--- /dev/null
+++ b/ImportStl.h
@@ -0,0 +1,34 @@
+//----------------------------------------------------------------------------
+// EgalTech 2014-2014
+//----------------------------------------------------------------------------
+// File : ImportStl.h Data : 04.04.14 Versione : 1.5d1
+// Contenuto : Dichiarazione della classe ImportStl.
+//
+//
+//
+// Modifiche : 04.04.14 DS Creazione modulo.
+//
+//
+//----------------------------------------------------------------------------
+
+#pragma once
+
+#include "/EgtDev/Include/EExImportStl.h"
+
+class Scanner ;
+class ISurfTriMesh ;
+
+//----------------------------------------------------------------------------
+class ImportStl : public IImportStl
+{
+ public :
+ virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup) ;
+
+ private :
+ bool LoadSolid( Scanner& TheScanner, bool& bEnd) ;
+ bool LoadTriangle( Scanner& TheScanner, ISurfTriMesh* pSTM, bool& bEnd) ;
+
+ private :
+ IGeomDB* m_pGDB ;
+ int m_nIdGroup ;
+} ;