3a31abedce
- miglioria in ExeSetBtlAuxDir per evitare errori successivi nell'interprete lua per le feature Variant.
808 lines
29 KiB
C++
808 lines
29 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2014-2014
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_Exchange.cpp Data : 20.09.14 Versione : 1.6e1
|
|
// Contenuto : Funzioni import/export per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 20.09.14 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "LUA_Base.h"
|
|
#include "AuxTools.h"
|
|
#include "DllExchange.h"
|
|
#include "DllExch3dm.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EXeConst.h"
|
|
#include "/EgtDev/Include/EXeCmdLogOff.h"
|
|
#include "/EgtDev/Include/EExImportDxf.h"
|
|
#include "/EgtDev/Include/EExImportStl.h"
|
|
#include "/EgtDev/Include/EExImport3MF.h"
|
|
#include "/EgtDev/Include/EExImportCnc.h"
|
|
#include "/EgtDev/Include/EExImportCsf.h"
|
|
#include "/EgtDev/Include/EExImportPnt.h"
|
|
#include "/EgtDev/Include/EExImportBtl.h"
|
|
#include "/EgtDev/Include/EExImportBtlx.h"
|
|
#include "/EgtDev/Include/EExImportOff.h"
|
|
#include "/EgtDev/Include/EExImportPly.h"
|
|
#include "/EgtDev/Include/EExExportDxf.h"
|
|
#include "/EgtDev/Include/EExExportStl.h"
|
|
#include "/EgtDev/Include/EExExport3MF.h"
|
|
#include "/EgtDev/Include/EExExportSvg.h"
|
|
#include "/EgtDev/Include/EExExportThreeJS.h"
|
|
#include "/EgtDev/Include/EE3Import3dm.h"
|
|
#include "/EgtDev/Include/EE3Export3dm.h"
|
|
#include "/EgtDev/Include/EGnStringUtils.h"
|
|
#include "/EgtDev/Include/EGnFileUtils.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
#include "/EgtDev/Include/EgtKeyCodes.h"
|
|
#include "/EgtDev/Include/SELkKeyProc.h"
|
|
#include "/EgtDev/Include/EGrScene.h"
|
|
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetFileType( const string& sFilePath)
|
|
{
|
|
// divido in nome e direttorio
|
|
string sFileDir, sFileName ;
|
|
if ( sFilePath.find( "\\") != string::npos)
|
|
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
|
else
|
|
sFileName = sFilePath ;
|
|
|
|
// recupero l'estensione
|
|
string sFileTitle, sFileExt ;
|
|
SplitLast( sFileName, ".", sFileTitle, sFileExt) ;
|
|
ToUpper( sFileExt) ;
|
|
|
|
if ( sFileExt == "NGE" || sFileExt == "VME" || sFileExt == "NHE" || sFileExt == "BWE" || sFileExt == "ICRS")
|
|
return FT_NGE ;
|
|
else if ( sFileExt == "NFE")
|
|
return FT_NFE ;
|
|
else if ( sFileExt == "DXF")
|
|
return FT_DXF ;
|
|
else if ( sFileExt == "STL")
|
|
return FT_STL ;
|
|
else if ( sFileExt == "3MF")
|
|
return FT_3MF ;
|
|
else if ( sFileExt == "3DM")
|
|
return FT_3DM ;
|
|
else if ( sFileExt == "OBJ")
|
|
return FT_OBJ ;
|
|
else if ( sFileExt == "OFF")
|
|
return FT_OFF ;
|
|
else if ( sFileExt == "PLY")
|
|
return FT_PLY ;
|
|
else if ( sFileExt == "CNC" || sFileExt == "XPI" || sFileExt == "MPF" || sFileExt == "ISO" || sFileExt == "EIA")
|
|
return FT_CNC ;
|
|
else if ( sFileExt == "HED" || sFileExt == "ENT" || sFileExt == "ENS")
|
|
return FT_CSF ;
|
|
else if ( sFileExt == "BTL")
|
|
return FT_BTL ;
|
|
else if ( sFileExt == "BTLX")
|
|
return FT_BTLX ;
|
|
else if ( sFileExt == "PNG" || sFileExt == "JPG" || sFileExt == "JPEG" || sFileExt == "BMP")
|
|
return FT_IMG ;
|
|
else if ( sFileExt == "PNT" || sFileExt == "XYZ")
|
|
return FT_PNT ;
|
|
else if ( sFileExt == "SVG")
|
|
return FT_SVG ;
|
|
else if ( sFileExt == "IGS" || sFileExt == "IGES")
|
|
return FT_IGES ;
|
|
else if ( sFileExt == "STP" || sFileExt == "STEP")
|
|
return FT_STEP ;
|
|
else if ( sFileExt == "SAT")
|
|
return FT_ACIS ;
|
|
else if ( sFileExt == "X_T" || sFileExt == "X_B")
|
|
return FT_PARASOLID ;
|
|
else if ( sFileExt == "JT")
|
|
return FT_JT ;
|
|
else if ( sFileExt == "WRL" || sFileExt == "WRZ")
|
|
return FT_VRML ;
|
|
else if ( sFileExt == "C3D")
|
|
return FT_C3D ;
|
|
else if ( sFileExt == "HTML")
|
|
return FT_HTML ;
|
|
else if ( sFileExt == "TSC")
|
|
return FT_TSC ;
|
|
else if ( sFileExt == "LUA")
|
|
return FT_LUA ;
|
|
else {
|
|
// emetto info
|
|
string sInfo = "File type (" + sFileExt + ") not recognized" ;
|
|
LOG_INFO( GetLogger(), sInfo.c_str())
|
|
return FT_NULL ;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetBtlAuxDir( const string& sBtlAuxDir)
|
|
{
|
|
bool bOk1 = MySetBtlAuxDir( sBtlAuxDir) ;
|
|
bool bOk2 = MySetBtlLuaData( LuaGetLuaLibsDir(), LuaGetLastRequire()) ;
|
|
return ( bOk1 && bOk2) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportBtl( const string& sFilePath, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file BTL
|
|
// preparo l'importatore
|
|
PtrOwner<IImportBtl> pImpBtl( MyCreateImportBtl()) ;
|
|
bOk = bOk && ! IsNull( pImpBtl) ;
|
|
// eseguo l'importazione (direttamente nella radice)
|
|
bOk = bOk && pImpBtl->Import( sFilePath, pGseCtx->m_pGeomDB, nFlag) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportBtl('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpBtl)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportBtlx( const string& sFilePath, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file BTLx
|
|
// preparo l'importatore
|
|
PtrOwner<IImportBtlx> pImpBtlx( MyCreateImportBtlx()) ;
|
|
bOk = bOk && ! IsNull( pImpBtlx) ;
|
|
// eseguo l'importazione (direttamente nella radice)
|
|
bOk = bOk && pImpBtlx->Import( sFilePath, pGseCtx->m_pGeomDB, nFlag) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportBtlx('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpBtlx)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportCnc( const string& sFilePath, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file CNC
|
|
// aggiungo un gruppo pezzo
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportCnc> pImpCnc( MyCreateImportCnc()) ;
|
|
bOk = bOk && ! IsNull( pImpCnc) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpCnc->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, nFlag) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportCnc('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpCnc)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportCsf( const string& sFilePath)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file CSF
|
|
// preparo l'importatore
|
|
PtrOwner<IImportCsf> pImpCsf( MyCreateImportCsf()) ;
|
|
bOk = bOk && ! IsNull( pImpCsf) ;
|
|
// eseguo l'importazione (direttamente nella radice)
|
|
bOk = bOk && pImpCsf->Import( sFilePath, pGseCtx->m_pGeomDB) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportCsf('" + StringToLuaString( sFilePath) + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpCsf)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportDxf( const string& sFilePath, double dScaleFactor)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file DXF
|
|
// aggiungo un gruppo pezzo
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportDxf> pImpDxf( MyCreateImportDxf()) ;
|
|
bOk = bOk && ! IsNull( pImpDxf) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpDxf->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, dScaleFactor) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportDxf('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( dScaleFactor) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpDxf)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportPnt( const string& sFilePath, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file PNT
|
|
// aggiungo un gruppo pezzo
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportPnt> pImpPnt( MyCreateImportPnt()) ;
|
|
bOk = bOk && ! IsNull( pImpPnt) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpPnt->Import( sFilePath, pGseCtx->m_pGeomDB, nPartId, nFlag) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportPnt('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpPnt)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportStl( const string& sFilePath, double dScaleFactor)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file STL
|
|
// aggiungo un gruppo pezzo e un gruppo layer
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportStl> pImpStl( MyCreateImportStl()) ;
|
|
bOk = bOk && ! IsNull( pImpStl) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpStl->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportStl('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( dScaleFactor) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpStl)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportOff( const string& sFilePath, double dScaleFactor)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file OFF
|
|
// aggiungo un gruppo pezzo e un gruppo layer
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportOff> pImpOff( MyCreateImportOff()) ;
|
|
bOk = bOk && ! IsNull( pImpOff) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpOff->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportOff('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( dScaleFactor) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpOff)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImportPly( const string& sFilePath, double dScaleFactor)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file PLY
|
|
// aggiungo un gruppo pezzo e un gruppo layer
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
int nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImportPly> pImpPly( MyCreateImportPly()) ;
|
|
bOk = bOk && ! IsNull( pImpPly) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImpPly->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, dScaleFactor) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImportPly('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( dScaleFactor) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImpPly)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImport3MF( const string& sFilePath, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
bool bOk = true ;
|
|
// importo il file 3MF
|
|
int nLayerId = GDB_ID_ROOT ;
|
|
// aggiungo un gruppo pezzo e un gruppo layer se non devo conservare la gerarchia del file
|
|
if ( ( nFlag & EI3FLAG_KEEP_GROUPS) == 0) {
|
|
int nPartId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, GDB_ID_ROOT, Frame3d()) ;
|
|
nLayerId = pGseCtx->m_pGeomDB->AddGroup( GDB_ID_NULL, nPartId, Frame3d()) ;
|
|
}
|
|
// preparo l'importatore
|
|
PtrOwner<IImport3MF> pImp3MF( MyCreateImport3MF()) ;
|
|
bOk = bOk && ! IsNull( pImp3MF) ;
|
|
// eseguo l'importazione
|
|
bOk = bOk && pImp3MF->Import( sFilePath, pGseCtx->m_pGeomDB, nLayerId, nFlag) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImport3MF('" + StringToLuaString( sFilePath) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImp3MF)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeImport3dm( const string& sFilePath)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
// se necessario, carico libreria exchange 3dm opzionale
|
|
if ( ! IsLoadedExch3dmDll() && LoadExch3dmDll( GetLogger(), ExeGetKey(), ExeGetNetHwKey()))
|
|
LOG_INFO( GetLogger(), MyGetEE3Version())
|
|
// importo il file 3dm
|
|
bool bOk = true ;
|
|
// preparo l'importatore
|
|
PtrOwner<IImport3dm> pImp3dm( MyCreateImport3dm()) ;
|
|
bOk = bOk && ! IsNull( pImp3dm) ;
|
|
// eseguo l'importazione
|
|
const DimensionStyle& DimSt = pGseCtx->m_dsCurr ;
|
|
double dExtLine = DimSt.dExtLineLen ;
|
|
double dArrLen = DimSt.dArrowLen ;
|
|
double dTextDist = DimSt.dTextDist ;
|
|
bool bLenIsMM = ( DimSt.nLenIsMM == 2 ? ExeUiUnitsAreMM() : ( DimSt.nLenIsMM != 0 )) ;
|
|
int nDecDig = DimSt.nDecDigit ;
|
|
string sFont = DimSt.sFont ;
|
|
double dTextHeight = DimSt.dTextHeight ;
|
|
bOk = bOk && pImp3dm->Import( sFilePath, pGseCtx->m_pGeomDB, GDB_ID_ROOT,
|
|
dTextHeight, dExtLine, dArrLen, dTextDist, bLenIsMM, nDecDig, sFont) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtImport3dm('" + StringToLuaString( sFilePath) + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
if ( ! IsNull( pImp3dm)) {
|
|
string sLog = "Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeAdvancedImportIsEnabled( void)
|
|
{
|
|
// verifico la chiave e le opzioni per l'import avanzato
|
|
unsigned int nOpt1, nOpt2 ;
|
|
int nOptExpDays ;
|
|
int nRet = GetKeyOptions( ExeGetKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
|
nOpt1, nOpt2, nOptExpDays) ;
|
|
if ( nRet != KEY_OK) {
|
|
std::string sErr = "Error on Key (EXA/" + ToString( nRet) + ")" ;
|
|
LOG_ERROR( GetLogger(), sErr.c_str()) ;
|
|
return false ;
|
|
}
|
|
if ( ( nOpt1 & ( KEYOPT_EEX_INPADV)) == 0 ||
|
|
nOptExpDays < GetCurrDay()) {
|
|
std::string sErr = "Warning on Key (EXA/OPT)" ;
|
|
LOG_ERROR( GetLogger(), sErr.c_str()) ;
|
|
return false ;
|
|
}
|
|
return true ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeAdvancedImport( const string& sFilePath, double dToler, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
// verifico che il formato sia supportato
|
|
int nFileType = ExeGetFileType( sFilePath) ;
|
|
if ( nFileType != FT_OBJ &&
|
|
nFileType != FT_IGES &&
|
|
nFileType != FT_STEP &&
|
|
nFileType != FT_ACIS &&
|
|
nFileType != FT_PARASOLID &&
|
|
nFileType != FT_JT &&
|
|
nFileType != FT_VRML &&
|
|
nFileType != FT_C3D) {
|
|
string sOut = "Error unknown format " + sFilePath ;
|
|
LOG_ERROR( GetLogger(), sOut.c_str())
|
|
return false ;
|
|
}
|
|
// verifico la chiave e le opzioni per l'import avanzato
|
|
if ( ! ExeAdvancedImportIsEnabled())
|
|
return false ;
|
|
// file intermedio
|
|
string sTempDir ; ExeGetTempDir( sTempDir) ;
|
|
string sFileOut = sTempDir + "\\AdvImp.nge" ;
|
|
EraseFile( sFileOut) ;
|
|
// eseguo il programma esterno di conversione
|
|
string sExec ;
|
|
#if defined( _WIN64)
|
|
sExec = "EgtConverterR64.exe" ;
|
|
#elif defined( _WIN32)
|
|
sExec = "EgtConverterR32.exe" ;
|
|
#endif
|
|
string sCmdLine = "\"" + sExec + "\" \"" + sFilePath + "\" \"" + sFileOut + "\" \"" +
|
|
ToString( dToler, 3) + "\" \"" + ToString( ExeGetDebugLevel()) + "\" \"" +
|
|
ExeGetKey() + "\" \"" + ExeGetLockId() + "\" \"" + ToString( nFlag) + "\"" ;
|
|
STARTUPINFO si ;
|
|
PROCESS_INFORMATION pi ;
|
|
ZeroMemory( &si, sizeof( si)) ;
|
|
si.cb = sizeof( si) ;
|
|
si.dwFlags = STARTF_USESHOWWINDOW ;
|
|
si.wShowWindow = SW_HIDE ;
|
|
ZeroMemory( &pi, sizeof( pi)) ;
|
|
if ( CreateProcess( NULL, stringtoW( sCmdLine), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) == FALSE)
|
|
return false ;
|
|
int nTime = 0 ;
|
|
bool bOk = true ;
|
|
while ( bOk) {
|
|
++ nTime ;
|
|
nTime = ( nTime % 200) ;
|
|
if ( ExeProcessEvents( int( nTime / 200.0 * 100), 100) == 1)
|
|
bOk = false ;
|
|
if ( WaitForSingleObject( pi.hProcess, 100) != WAIT_TIMEOUT)
|
|
break ;
|
|
}
|
|
if ( ! bOk)
|
|
TerminateProcess( pi.hProcess, 98) ;
|
|
DWORD nExitCode = 99 ;
|
|
GetExitCodeProcess( pi.hProcess, &nExitCode) ;
|
|
bOk = bOk && ( nExitCode == 0) ;
|
|
CloseHandle( pi.hProcess) ;
|
|
CloseHandle( pi.hThread) ;
|
|
// apro il file intermedio
|
|
CmdLogOff cmdLogOff ;
|
|
bOk = bOk && ExeInsertFile( sFileOut) ;
|
|
cmdLogOff.Reset() ;
|
|
if ( ExeGetDebugLevel() < 5)
|
|
EraseFile( sFileOut) ;
|
|
// aggiorno stato file corrente
|
|
if ( pGseCtx->m_sFilePath.empty())
|
|
pGseCtx->m_sFilePath = sFilePath ;
|
|
ExeSetModified() ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAdvancedImport('" + StringToLuaString( sFilePath) + "'," +
|
|
ToString( dToler) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// scrivo il log
|
|
{
|
|
string sLog = "Advanced Import File " + sFilePath ;
|
|
LOG_INFO( GetLogger(), sLog.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExportDxf( int nId, const string& sFilePath, int nFlag, int nFilter)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
bool bOk = true ;
|
|
// esporto il file DXF
|
|
// preparo l'esportatore
|
|
PtrOwner<IExportDxf> pExpDxf( MyCreateExportDxf()) ;
|
|
bOk = bOk && ! IsNull( pExpDxf) ;
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExpDxf->SetOptions( nFilter, nFlag) ;
|
|
bOk = bOk && pExpDxf->Export( pGeomDB, nId, sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExportDxf(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExportStl( int nId, const string& sFilePath, int nFilter)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
bool bOk = true ;
|
|
// esporto il file STL
|
|
// preparo l'esportatore
|
|
PtrOwner<IExportStl> pExpStl( MyCreateExportStl()) ;
|
|
bOk = bOk && ! IsNull( pExpStl) ;
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExpStl->SetOptions( nFilter) ;
|
|
bOk = bOk && pExpStl->Export( pGeomDB, nId, sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExportStl(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExport3MF( int nId, const string& sFilePath, int nFilter)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
bool bOk = true ;
|
|
// esporto il file 3MF
|
|
// preparo l'esportatore
|
|
PtrOwner<IExport3MF> pExp3MF( MyCreateExport3MF()) ;
|
|
bOk = bOk && ! IsNull( pExp3MF) ;
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExp3MF->SetOptions( nFilter) ;
|
|
bOk = bOk && pExp3MF->Export( pGeomDB, nId, sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExport3MF(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExport3dm( int nId, const string& sFilePath, int nFilter)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
// se necessario, carico libreria exchange 3dm opzionale
|
|
if ( ! IsLoadedExch3dmDll() && LoadExch3dmDll( GetLogger(), ExeGetKey(), ExeGetNetHwKey()))
|
|
LOG_INFO( GetLogger(), MyGetEE3Version())
|
|
// esporto il file 3dm
|
|
bool bOk = true ;
|
|
// preparo l'esportatore
|
|
PtrOwner<IExport3dm> pExp3dm( MyCreateExport3dm()) ;
|
|
bOk = bOk && ! IsNull( pExp3dm) ;
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExp3dm->SetOptions( nFilter) ;
|
|
bOk = bOk && pExp3dm->Export( pGeomDB, nId, sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExport3dm(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "')" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExportSvg( int nId, const string& sFilePath, int nFilter)
|
|
{
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
bool bOk = true ;
|
|
// esporto il file SVG
|
|
// preparo l'esportatore
|
|
PtrOwner<IExportSvg> pExpSvg( MyCreateExportSvg()) ;
|
|
bOk = bOk && ! IsNull( pExpSvg) ;
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExpSvg->SetOptions( nFilter) ;
|
|
bOk = bOk && pExpSvg->Export( pGeomDB, nId, sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExportSvg(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFilter) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetThreeJSLibDir( const string& sThreeJSLibDir)
|
|
{
|
|
return MySetThreeJSLibDir( sThreeJSLibDir) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeExportThreeJS( int nId, const string& sFilePath, int nFilter)
|
|
{
|
|
IEGrScene* pScene = GetCurrScene();
|
|
VERIFY_SCENE( pScene, false) ;
|
|
IGeomDB* pGeomDB = GetCurrGeomDB() ;
|
|
VERIFY_GEOMDB( pGeomDB, false)
|
|
bool bOk = true ;
|
|
// esporto il file per ThreeJS
|
|
// preparo l'esportatore
|
|
PtrOwner<IExportThreeJS> pExpThreeJS( MyCreateExportThreeJS()) ;
|
|
bOk = bOk && ! IsNull( pExpThreeJS) ;
|
|
|
|
// eseguo l'esportazione
|
|
bOk = bOk && pExpThreeJS->SetOptions( nFilter) ;
|
|
bOk = bOk && pExpThreeJS->Export( pGeomDB, nId, pScene, ExeUiUnitsAreMM(), sFilePath) ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtExportThreeJS(" + ToString( nId) + ",'" +
|
|
StringToLuaString( sFilePath) + "'," +
|
|
ToString( nFilter) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|