diff --git a/EgtExchange.vcxproj b/EgtExchange.vcxproj index 2105f9f..f356cd5 100644 --- a/EgtExchange.vcxproj +++ b/EgtExchange.vcxproj @@ -217,19 +217,101 @@ copy $(TargetPath) \EgtProg\Dll64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtExchange.vcxproj.filters b/EgtExchange.vcxproj.filters index 1a29e3f..5fa4640 100644 --- a/EgtExchange.vcxproj.filters +++ b/EgtExchange.vcxproj.filters @@ -129,6 +129,252 @@ File di intestazione + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + + + File di intestazione\Include + diff --git a/ExportThreeJS.cpp b/ExportThreeJS.cpp index e239ae7..7309b4a 100644 --- a/ExportThreeJS.cpp +++ b/ExportThreeJS.cpp @@ -13,51 +13,48 @@ //--------------------------- Include ---------------------------------------- #include "stdafx.h" -#include "ExportThreeJS.h" #include "DllMain.h" +#include "ExportThreeJS.h" #include "/EgtDev/Include/EExDllMain.h" +#include "/EgtDev/Include/EGkGeoConst.h" +#include "/EgtDev/Include/EGkFrame3d.h" #include "/EgtDev/Include/EGkGeomDB.h" +#include "/EgtDev/Include/EGkGdbIterator.h" +#include "/EgtDev/Include/EGkGeoVector3d.h" +#include "/EgtDev/Include/EGkGeoPoint3d.h" +#include "/EgtDev/Include/EGkGeoFrame3d.h" +#include "/EgtDev/Include/EGKCurve.h" +#include "/EgtDev/Include/EGkCurveLine.h" +#include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkSurfFlatRegion.h" #include "/EgtDev/Include/EGkSurfTriMesh.h" -#include "/EgtDev/Include/EGkGdbIterator.h" -#include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" -#include "/EgtDev/Include/EgtStringConverter.h" -#include "/EgtDev/Include/EgtPointerOwner.h" -#include -#include "/EgtDev/Include/EGkGeoVector3d.h" -#include "/EgtDev/Include/EGkCurveLine.h" -#include "/EgtDev/Include/EGkGeoPoint3d.h" -#include "/EgtDev/Include/EGKCurve.h" -#include "/EgtDev/Include/EGkGeoConst.h" -#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkSurfBezier.h" -#include "/EgtDev/Include/EGkGeoFrame3d.h" -#include "/EgtDev/Include/EGkFrame3d.h" +#include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGkExtDimension.h" #include "/EgtDev/Include/EGrScene.h" -#include "/EgtDev/Include/EGkCurveComposite.h" +#include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" +#include "/EgtDev/Include/EgtStringConverter.h" +#include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Extern/libzip/Include/zip.h" #include "/EgtDev/Extern/libzip/Include/zipconf.h" - using namespace std ; //---------------------------------------------------------------------------- -string ExportThreeJS::m_sThreeJSAuxDir = "C:\\EgtData\\ThreeJSLib"; +const double ANG_TOL_STD_DEG = 15 ; +//---------------------------------------------------------------------------- +string ExportThreeJS::m_sThreeJSLibDir = "C:\\EgtData\\ThreeJSLib"; //---------------------------------------------------------------------------- bool -SetThreeJSAuxDir( const string& sThreeJSAuxDir) +SetThreeJSLibDir( const string& sThreeJSLibDir) { - ExportThreeJS::m_sThreeJSAuxDir = sThreeJSAuxDir ; - return ExistsDirectory( sThreeJSAuxDir ) ; + ExportThreeJS::m_sThreeJSLibDir = sThreeJSLibDir ; + return ExistsDirectory( sThreeJSLibDir ) ; } - //---------------------------------------------------------------------------- IExportThreeJS* CreateExportThreeJS( void) @@ -113,7 +110,6 @@ ExportThreeJS::CreateFolderSpace( const string& SFileName, const string& sUserPa if ( ! CopyFileEgt( sLibPath + "Controls\\ViewCubeControls.js", sDirLib + "\\Controls\\ViewCubeControls.js")) return false ; - if ( ! CopyFileEgt( sLibPath + "Css\\Bootstrap\\bootstrap.min.css", sDirLib + "\\Css\\Bootstrap\\bootstrap.min.css")) return false ; if ( ! CopyFileEgt( sLibPath + "Css\\Bootstrap\\bootstrap-icons.css", sDirLib + "\\Css\\Bootstrap\\bootstrap-icons.css")) @@ -145,14 +141,12 @@ ExportThreeJS::CreateFolderSpace( const string& SFileName, const string& sUserPa if ( ! CopyFileEgt( sLibPath + "three.module.js", sDirLib + "\\three.module.js")) return false ; - if ( ! CopyFileEgt( sLibPath + "info.txt", sUserPath + "\\info.txt")) return false ; return true ; } - //---------------------------------------------------------------------------- bool ExportThreeJS::CompressAll( const string& sFile) @@ -161,9 +155,10 @@ ExportThreeJS::CompressAll( const string& sFile) string sFileName = GetFileName( sFile) ; //.html string sFileTitle = GetFileTitleEgt( sFile) ; // no .html + // Preparo zip int errorp ; - zip_t * zipper = zip_open((( sDir + "\\" + sFileTitle) + ".zip").c_str(), ZIP_CREATE | ZIP_EXCL, &errorp) ; - if ( zipper == nullptr) { + zip_t* pZipper = zip_open( (( sDir + "\\" + sFileTitle) + ".zip").c_str(), ZIP_CREATE | ZIP_TRUNCATE, &errorp) ; + if ( pZipper == nullptr) { zip_error_t ziperror ; zip_error_init_with_code( &ziperror, errorp) ; LOG_ERROR( GetEExLogger(), ( "Failed to open output file " + sFileName + " or found a file with the same name: " + zip_error_strerror( &ziperror)).c_str()) ; @@ -171,157 +166,147 @@ ExportThreeJS::CompressAll( const string& sFile) return false ; } - zip_source_t * source = zip_source_file( zipper, ( sFile).c_str(), 0, 0) ; - if ( zip_file_add( zipper, sFileName.c_str(), source, ZIP_FL_ENC_UTF_8) < 0) + // File html + zip_source_t* pSource = zip_source_file( pZipper, ( sFile).c_str(), 0, 0) ; + if ( zip_file_add( pZipper, sFileName.c_str(), pSource, ZIP_FL_ENC_UTF_8) == -1) return false ; - int nLibIndex = zip_dir_add( zipper, "Lib", ZIP_FL_ENC_UTF_8) ; - - // Lib - - int nControlIndex = zip_dir_add( zipper, "Lib\\Controls", ZIP_FL_ENC_UTF_8) ; - int nCssIndex = zip_dir_add( zipper, "Lib\\Css", ZIP_FL_ENC_UTF_8) ; - int nImmIndex = zip_dir_add( zipper, "Lib\\Immagini", ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\jquery.js").c_str(), 0, 0) ; - int nJQndex = zip_file_add( zipper, "Lib\\jquery.js", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\three.module.js").c_str(), 0, 0) ; - int nThreeIndex = zip_file_add( zipper, "Lib\\three.module.js", source, ZIP_FL_ENC_UTF_8) ; + // Lib + int nLibIndex = zip_dir_add( pZipper, "Lib", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\jquery.js").c_str(), 0, 0) ; + int nJQndex = zip_file_add( pZipper, "Lib\\jquery.js", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\three.module.js").c_str(), 0, 0) ; + int nThreeIndex = zip_file_add( pZipper, "Lib\\three.module.js", pSource, ZIP_FL_ENC_UTF_8) ; // Controls - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Controls\\OrbitControlsM.js" ).c_str(), 0, 0) ; - int nOBIndex = zip_file_add( zipper, "Lib\\Controls\\OrbitControlsM.js", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Controls\\ViewCubeControls.js" ).c_str(), 0, 0) ; - int nVCCIndex = zip_file_add( zipper, "Lib\\Controls\\ViewCubeControls.js", source, ZIP_FL_ENC_UTF_8) ; + int nControlIndex = zip_dir_add( pZipper, "Lib\\Controls", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Controls\\OrbitControlsM.js" ).c_str(), 0, 0) ; + int nOBIndex = zip_file_add( pZipper, "Lib\\Controls\\OrbitControlsM.js", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Controls\\ViewCubeControls.js" ).c_str(), 0, 0) ; + int nVCCIndex = zip_file_add( pZipper, "Lib\\Controls\\ViewCubeControls.js", pSource, ZIP_FL_ENC_UTF_8) ; // Css - int nCssBIndex = zip_dir_add( zipper, "Lib\\Css\\Bootstrap", ZIP_FL_ENC_UTF_8) ; - int nCssfIndex = zip_dir_add( zipper, "Lib\\Css\\fontawesome", ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\StileScena.css").c_str(), 0, 0) ; - int nSCIndex = zip_file_add( zipper, "Lib\\Css\\StileScena.css", source, ZIP_FL_ENC_UTF_8) ; + int nCssIndex = zip_dir_add( pZipper, "Lib\\Css", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\StileScena.css").c_str(), 0, 0) ; + int nSCIndex = zip_file_add( pZipper, "Lib\\Css\\StileScena.css", pSource, ZIP_FL_ENC_UTF_8) ; - // Bootstrap - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\Bootstrap\\bootstrap.min.css" ).c_str(), 0, 0) ; - int nBMIndex = zip_file_add( zipper, "Lib\\Css\\Bootstrap\\bootstrap.min.css", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\Bootstrap\\bootstrap-icons.css").c_str(), 0, 0) ; - int nBIIndex = zip_file_add( zipper, "Lib\\Css\\Bootstrap\\bootstrap-icons.css", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\Bootstrap\\fontawesomeall.css").c_str(), 0, 0) ; - int nfaIndex = zip_file_add( zipper, "Lib\\Css\\Bootstrap\\fontawesomeall.css", source, ZIP_FL_ENC_UTF_8) ; + // Css -> Bootstrap + int nCssBIndex = zip_dir_add( pZipper, "Lib\\Css\\Bootstrap", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\Bootstrap\\bootstrap.min.css" ).c_str(), 0, 0) ; + int nBMIndex = zip_file_add( pZipper, "Lib\\Css\\Bootstrap\\bootstrap.min.css", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\Bootstrap\\bootstrap-icons.css").c_str(), 0, 0) ; + int nBIIndex = zip_file_add( pZipper, "Lib\\Css\\Bootstrap\\bootstrap-icons.css", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\Bootstrap\\fontawesomeall.css").c_str(), 0, 0) ; + int nfaIndex = zip_file_add( pZipper, "Lib\\Css\\Bootstrap\\fontawesomeall.css", pSource, ZIP_FL_ENC_UTF_8) ; + // Css -> fontawesome + int nCssfIndex = zip_dir_add( pZipper, "Lib\\Css\\fontawesome", ZIP_FL_ENC_UTF_8) ; + + // Css -> fontawesome -> css + int nfaCIndex = zip_dir_add( pZipper, "Lib\\Css\\fontawesome\\css", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\fontawesome\\css\\all.min.css").c_str(), 0, 0) ; + int nfaAMIndex = zip_file_add( pZipper, "Lib\\Css\\fontawesome\\css\\all.min.css", pSource, ZIP_FL_ENC_UTF_8) ; - //fontawesome - int nfaCIndex = zip_dir_add( zipper, "Lib\\Css\\fontawesome\\css", ZIP_FL_ENC_UTF_8) ; - int nfaWIndex = zip_dir_add( zipper, "Lib\\Css\\fontawesome\\webfonts", ZIP_FL_ENC_UTF_8) ; - - //fontawesome -> css - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\fontawesome\\css\\all.min.css").c_str(), 0, 0) ; - int nfaAMIndex = zip_file_add( zipper, "Lib\\Css\\fontawesome\\css\\all.min.css", source, ZIP_FL_ENC_UTF_8) ; + // Css -> fontawesome -> webfonts + int nfaWIndex = zip_dir_add( pZipper, "Lib\\Css\\fontawesome\\webfonts", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\fontawesome\\webfonts\\fa-brands-400.ttf").c_str(), 0, 0) ; + int nfafbIndex = zip_file_add( pZipper, "Lib\\Css\\fontawesome\\webfonts\\fa-brands-400.ttf", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\fontawesome\\webfonts\\fa-regular-400.ttf").c_str(), 0, 0) ; + int nfafrIndex = zip_file_add( pZipper, "Lib\\Css\\fontawesome\\webfonts\\fa-regular-400.ttf", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\fontawesome\\webfonts\\fa-solid-900.ttf").c_str(), 0, 0) ; + int nfafsIndex = zip_file_add( pZipper, "Lib\\Css\\fontawesome\\webfonts\\fa-solid-900.ttf", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Css\\fontawesome\\webfonts\\fa-v4compatibility.ttf").c_str(), 0, 0) ; + int nfafvIndex = zip_file_add( pZipper, "Lib\\Css\\fontawesome\\webfonts\\fa-v4compatibility.ttf", pSource, ZIP_FL_ENC_UTF_8) ; - //fontawesome -> webfonts - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\fontawesome\\webfonts\\fa-brands-400.ttf").c_str(), 0, 0) ; - int nfafbIndex = zip_file_add( zipper, "Lib\\Css\\fontawesome\\webfonts\\fa-brands-400.ttf", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\fontawesome\\webfonts\\fa-regular-400.ttf").c_str(), 0, 0) ; - int nfafrIndex = zip_file_add( zipper, "Lib\\Css\\fontawesome\\webfonts\\fa-regular-400.ttf", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\fontawesome\\webfonts\\fa-solid-900.ttf").c_str(), 0, 0) ; - int nfafsIndex = zip_file_add( zipper, "Lib\\Css\\fontawesome\\webfonts\\fa-solid-900.ttf", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Css\\fontawesome\\webfonts\\fa-v4compatibility.ttf").c_str(), 0, 0) ; - int nfafvIndex = zip_file_add( zipper, "Lib\\Css\\fontawesome\\webfonts\\fa-v4compatibility.ttf", source, ZIP_FL_ENC_UTF_8) ; - - //Immagini - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Immagini\\LogoQ.png").c_str(), 0, 0) ; - int nIQIndex = zip_file_add( zipper, "Lib\\Immagini\\LogoQ.png", source, ZIP_FL_ENC_UTF_8) ; - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\Immagini\\LogoV.png").c_str(), 0, 0) ; - int nIVIndex = zip_file_add( zipper, "Lib\\Immagini\\LogoV.png", source, ZIP_FL_ENC_UTF_8) ; + // Immagini + int nImmIndex = zip_dir_add( pZipper, "Lib\\Immagini", ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Immagini\\LogoQ.png").c_str(), 0, 0) ; + int nIQIndex = zip_file_add( pZipper, "Lib\\Immagini\\LogoQ.png", pSource, ZIP_FL_ENC_UTF_8) ; + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\Immagini\\LogoV.png").c_str(), 0, 0) ; + int nIVIndex = zip_file_add( pZipper, "Lib\\Immagini\\LogoV.png", pSource, ZIP_FL_ENC_UTF_8) ; - //file info - source = zip_source_file( zipper, ( m_sThreeJSAuxDir + "\\info.txt").c_str(), 0, 0) ; - int nInfoIndex = zip_file_add( zipper, "info.txt", source, ZIP_FL_ENC_UTF_8) ; + // File info + pSource = zip_source_file( pZipper, ( m_sThreeJSLibDir + "\\info.txt").c_str(), 0, 0) ; + int nInfoIndex = zip_file_add( pZipper, "info.txt", pSource, ZIP_FL_ENC_UTF_8) ; - - - int nFin = zip_close( zipper) ; - if ( nFin == -1) { - zip_error_t* ziperror = zip_get_error( zipper) ; + // Salvo il file zip + if ( zip_close( pZipper) == -1) { + zip_error_t* ziperror = zip_get_error( pZipper) ; LOG_ERROR( GetEExLogger(), ( "Failed to open output file " + sFileName + ": " + zip_error_strerror( ziperror)).c_str()) ; EraseFile( sFile) ; return false ; } + + // Cancello il file html EraseFile( sFile) ; return true ; } - //---------------------------------------------------------------------------- bool -ExportThreeJS::Export( IGeomDB* pGDB, int nId, const string& sFile, IEGrScene* pScene, bool bUdm) +ExportThreeJS::Export( IGeomDB* pGDB, int nId, IEGrScene* pScene, bool bUdm, const string& sFile) { - // verifico il DB geometrico - if ( pGDB == nullptr) { - LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on GeomDB") - return false ; - } - - // verifico l'Id dell'oggetto da esportare - if ( ! pGDB->ExistsObj( nId)) { - LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on Id") - return false ; - } - - // creo la cartella contenente le librerie e i file - //if ( ! CreateFolderSpace( "ProvaProvaProva", "C:\\Users\\riccardo.elitropi\\Desktop\\", "C:\\Users\\riccardo.elitropi\\Desktop\\Lib\\")) //<========================= = MODIFICARE - // return false ; - - // creo il frame - m_frTHREEJSFrame.Set( ORIG, Y_AX, Z_AX, X_AX) ; - - // apro il file di testo in scrittura - m_Writer.Close() ; - if ( ! m_Writer.Init( sFile)) { - LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on open file") - return false ; - } - - // prelevo le unità di misura - m_bUdm_mm = bUdm ; - m_sUdm = "in" ; - if ( m_bUdm_mm) { - m_sUdm = "mm" ; - } - - // prelevo il Box3D globale (per ingombro e punto luce) - BBox3d b3Globbox ; - pGDB->GetGlobalBBox( nId, b3Globbox, BBF_ONLY_VISIBLE) ; - b3Globbox.GetMinDim( m_ptMin, m_dimX, m_dimY, m_dimZ) ; - m_ptMin.ToLoc( m_frTHREEJSFrame) ; - - // creazione parte iniziale della pagina html - bool bOk = HeadAmbient( pScene, pGDB, nId) ; - - // creo un iteratore - PtrOwner pIter( CreateGdbIterator( pGDB)) ; - if ( IsNull( pIter)) + // verifico il DB geometrico + if ( pGDB == nullptr) { + LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on GeomDB") return false ; - pIter->GoTo( nId) ; - // esporto l'oggetto e i suoi eventuali figli - bOk = ExportObject( *pIter, pGDB, m_nGroupCount) ; - // fine creazione menù con elementi globali + } - // aggiungo tutto ciò che è nella scena nel nodo radice - m_Writer.OutText( " groupRoot.add(group0)") ; + // verifico l'Id dell'oggetto da esportare + if ( ! pGDB->ExistsObj( nId)) { + LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on Id") + return false ; + } - // creazione parte finale della pagina html - bOk = FinishAmbient() ; + // creo il frame + m_frTHREEJSFrame.Set( ORIG, Y_AX, Z_AX, X_AX) ; - // chiudo il file - if ( ! m_Writer.Close()) - bOk = false ; + // apro il file di testo in scrittura + m_Writer.Close() ; + if ( ! m_Writer.Init( sFile)) { + LOG_ERROR( GetEExLogger(), "ExportThreeJS : Error on open file") + return false ; + } - // comprimo la cartella - if ( ! CompressAll( sFile)) - bOk = false ; + // determino le unità di misura + m_bUdm_mm = bUdm ; + m_sUdm = ( m_bUdm_mm ? "mm" : "in") ; - return bOk; + // calcolo il Box3D globale (per ingombro e punto luce) + BBox3d b3GlobBox ; + pGDB->GetGlobalBBox( nId, b3GlobBox, BBF_ONLY_VISIBLE) ; + b3GlobBox.GetMinDim( m_ptMin, m_dimX, m_dimY, m_dimZ) ; + m_ptMin.ToLoc( m_frTHREEJSFrame) ; + // creazione parte iniziale della pagina html + if ( ! HeadAmbient( pScene, pGDB, nId)) + return false ; + + // esporto l'oggetto e i suoi eventuali figli + PtrOwner pIter( CreateGdbIterator( pGDB)) ; + if ( IsNull( pIter)) + return false ; + pIter->GoTo( nId) ; + if ( ! ExportObject( *pIter, pGDB, m_nGroupCount)) + return false ; + + // aggiungo tutto ciò che è nella scena nel nodo radice + m_Writer.OutText( " groupRoot.add(group0)") ; + + // creazione parte finale della pagina html + if ( ! FinishAmbient()) + return false ; + + // chiudo il file + if ( ! m_Writer.Close()) + return false ; + + // comprimo la cartella + if ( ! CompressAll( sFile)) + return false ; + + return true ; } //---------------------------------------------------------------------------- @@ -333,32 +318,30 @@ ExportThreeJS::HeadAmbient( IEGrScene* pScene, IGeomDB* pGDB, int nId) // ================================================================ double dAngVertDeg, dAngOrizzDeg, dDist ; // parametri della telecamera - Vector3d vtDirCamera ; double dSnapStep ; // parametri della griglia int nExtStep ; - // controllo che il puntatore alla Scena non sia nullo + // se esiste una scena associata al DB geometrico if ( pScene != nullptr) { - // prelevo i parametri della camera da EGTCAM5 - pScene->GetOrthoCamParam( &m_dHalfWidth, &m_dHalfHeight, &m_ZNear, &m_ZFar) ; + // prelevo i parametri della camera + pScene->GetOrthoCamParam( &m_dHalfWidth, &m_dHalfHeight, &m_dZNear, &m_dZFar) ; m_ptCenter = pScene->GetCenter() ; pScene->GetCamera( &dAngVertDeg, &dAngOrizzDeg, &dDist) ; - vtDirCamera = FromSpherical( 1, dAngVertDeg, dAngOrizzDeg) ; + Vector3d vtDirCamera = FromSpherical( 1, dAngVertDeg, dAngOrizzDeg) ; m_ptCamera = m_ptCenter + dDist * vtDirCamera ; m_dDistance = dDist ; m_dCameraPhi = dAngVertDeg ; m_dCameraTheta = dAngOrizzDeg ; - - // prelevo i parametri della griglia + // prelevo i parametri della griglia pScene->GetGridParam( dSnapStep, nExtStep) ; m_bShowGrid = ! pScene->GetShowGrid() ; } + // altrimenti imposto dei parametri standard else { - // se non ho una Scena allora imposto dei parametri di Default (per griglia e telecamera) m_dHalfWidth = 559.67 ; m_dHalfHeight = 337.53 ; - m_ZNear = -24000 ; - m_ZFar = 26000 ; + m_dZNear = -24000 ; + m_dZFar = 26000 ; m_ptCenter = Point3d( 0, 0, 0 ) ; m_ptCamera = m_ptCenter + 1000 * FromSpherical( 1, 72.3684, 185.9832 ) ; m_dCameraPhi = 72.3684 ; @@ -367,1089 +350,1024 @@ ExportThreeJS::HeadAmbient( IEGrScene* pScene, IGeomDB* pGDB, int nId) dSnapStep = 10 ; nExtStep = 100 ; } - - m_sPath = "" ; // percorso relativo all'interno delle cartelle (modificabile per future implementazioni) - // scrittura parte iniziale del codice e librerie + string sPath = "" ; // percorso relativo all'interno delle cartelle (modificabile per future implementazioni) - m_Writer.OutText( "") ; - m_Writer.OutText( "") ; - m_Writer.OutText( " ") ; // - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( " "); - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; // - m_Writer.OutText( " ") ; // + // scrittura parte iniziale del codice e librerie + m_Writer.OutText( "") ; + m_Writer.OutText( "") ; + m_Writer.OutText( " ") ; // + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( " "); + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( " ") ; // + m_Writer.OutText( " ") ; // - // --- Div che contiene il caricamento della pagina + // --- Div che contiene il caricamento della pagina + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( " ") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
EGALWARE
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
'A new way to create between hardware and software'
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
"); + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; + m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( " ") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
EGALWARE
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
'A new way to create between hardware and software'
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
"); - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; - m_Writer.OutText( "
") ; + // --- Div che contiene il canvas per la scena + m_Writer.OutText( "
") ; - // --- Div che contiene il canvas per la scena + // --- bottone laterale sinistro del menu (overlapping) + m_Writer.OutText( " ") ; - m_Writer.OutText( "
") ; + // --- Menu in basso con misure, ingombri e selezione + m_Writer.OutText( " ") ; - // --- bottone laterale sinistro del menu (overlapping) + // --- Contenitore del Logo + m_Writer.OutText( " ") ; - m_Writer.OutText( " ") ; + // --- Menu a destra con i controlli + m_Writer.OutText( "