diff --git a/EgtExchange.rc b/EgtExchange.rc index e4e05b1..c016f1e 100644 Binary files a/EgtExchange.rc and b/EgtExchange.rc differ diff --git a/EgtExchange.sln b/EgtExchange.sln index d4ae855..80b9273 100644 --- a/EgtExchange.sln +++ b/EgtExchange.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.645 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35521.163 d17.12 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EgtExchange", "EgtExchange.vcxproj", "{80FCBEA4-1883-4542-939D-8582E66D8D51}" EndProject diff --git a/EgtExchange.vcxproj b/EgtExchange.vcxproj index 272f4ff..fb761ab 100644 --- a/EgtExchange.vcxproj +++ b/EgtExchange.vcxproj @@ -232,6 +232,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -330,6 +331,7 @@ copy $(TargetPath) \EgtProg\Dll64 + @@ -372,6 +374,7 @@ copy $(TargetPath) \EgtProg\Dll64 + diff --git a/EgtExchange.vcxproj.filters b/EgtExchange.vcxproj.filters index 5fa4640..1494e6d 100644 --- a/EgtExchange.vcxproj.filters +++ b/EgtExchange.vcxproj.filters @@ -375,6 +375,12 @@ File di intestazione\Include + + File di intestazione + + + File di intestazione\Include + @@ -455,6 +461,9 @@ File di origine + + File di origine + diff --git a/Export3MF.cpp b/Export3MF.cpp index 3f2b272..8b9c910 100644 --- a/Export3MF.cpp +++ b/Export3MF.cpp @@ -22,8 +22,6 @@ #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" diff --git a/ExportDxf.cpp b/ExportDxf.cpp index cd2cbd1..61b1221 100644 --- a/ExportDxf.cpp +++ b/ExportDxf.cpp @@ -33,8 +33,6 @@ #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtStringDecoder.h" #include "/EgtDev/Include/EgtPointerOwner.h" diff --git a/ExportStl.cpp b/ExportStl.cpp index 88d36c6..777c597 100644 --- a/ExportStl.cpp +++ b/ExportStl.cpp @@ -21,8 +21,6 @@ #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 diff --git a/ExportSvg.cpp b/ExportSvg.cpp index f1642ca..6a70a6b 100644 --- a/ExportSvg.cpp +++ b/ExportSvg.cpp @@ -28,8 +28,6 @@ #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGkStringUtils3d.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 diff --git a/ImportBtl.cpp b/ImportBtl.cpp index 3df3b91..55bad26 100644 --- a/ImportBtl.cpp +++ b/ImportBtl.cpp @@ -20,8 +20,6 @@ #include "/EgtDev/Include/EGkStmStandard.h" #include "/EgtDev/Include/EGkStringUtils3d.h" #include "/EgtDev/Include/EGnFileUtils.h" -#include "/EgtDev/Include/EgtKeyCodes.h" -#include "/EgtDev/Include/EgtStringEncoder.h" #include "/EgtDev/Include/EgtStringEncoder.h" using namespace std ; diff --git a/ImportCnc.cpp b/ImportCnc.cpp index 699d720..32b73a2 100644 --- a/ImportCnc.cpp +++ b/ImportCnc.cpp @@ -25,8 +25,6 @@ #include "/EgtDev/Include/EGkCurveComposite.h" #include "/EgtDev/Include/EGkArcSpecial.h" #include "/EgtDEv/Include/EGnScanner.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" diff --git a/ImportCsf.cpp b/ImportCsf.cpp index 55aa056..fb1c26a 100644 --- a/ImportCsf.cpp +++ b/ImportCsf.cpp @@ -25,8 +25,6 @@ #include "/EgtDev/Include/EGkExtText.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnFileUtils.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include diff --git a/ImportDxf.cpp b/ImportDxf.cpp index a0ced2a..d680079 100644 --- a/ImportDxf.cpp +++ b/ImportDxf.cpp @@ -19,12 +19,9 @@ #include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EGkGdbIterator.h" #include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" using namespace std ; - //---------------------------------------------------------------------------- IImportDxf* CreateImportDxf( void) diff --git a/ImportOff.cpp b/ImportOff.cpp new file mode 100644 index 0000000..65ab3be --- /dev/null +++ b/ImportOff.cpp @@ -0,0 +1,155 @@ +//---------------------------------------------------------------------------- +// EgalTech 2024-2024 +//---------------------------------------------------------------------------- +// File : ImportOff.cpp Data : 28.11.24 Versione : 2.6k2 +// Contenuto : Implementazione della classe per l'importazione di OFF. +// +// +// +// Modifiche : 28.11.24 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +//--------------------------- Include ---------------------------------------- +#include "stdafx.h" +#include "ImportOff.h" +#include "DllMain.h" +#include "/EgtDev/Include/EExDllMain.h" +#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" +#include "/EgtDev/Include/EgtPointerOwner.h" + +using namespace std ; + +//---------------------------------------------------------------------------- +IImportOff* +CreateImportOff( void) +{ + // verifico la chiave e le opzioni + if ( ! VerifyKey( KEYOPT_EEX_INPBASE)) + return nullptr ; + // creo l'oggetto + return static_cast ( new( nothrow) ImportOff) ; +} + +//---------------------------------------------------------------------------- +bool +ImportOff::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor) +{ + // verifico il DB geometrico + if ( pGDB == nullptr) { + LOG_ERROR( GetEExLogger(), "ImportOff : Error on GeomDB") + return false ; + } + m_pGDB = pGDB ; + + // verifico l'Id di gruppo + if ( ! m_pGDB->ExistsObj( nIdGroup)) { + LOG_ERROR( GetEExLogger(), "ImportOff : Error on IdGroup") + return false ; + } + m_nIdGroup = nIdGroup ; + + // verifico il fattore di scala + if ( dScaleFactor < EPS_SMALL) { + LOG_ERROR( GetEExLogger(), "ImportOff : Error on ScaleFactor too small (minimum 0.001).") + return false ; + } + m_dScaleFactor = dScaleFactor ; + + // inizializzo lo scanner + if ( ! m_theScanner.Init( sFile, "#")) { + LOG_ERROR( GetEExLogger(), "ImportOff : Error on Init") + return false ; + } + + // lettura intestazione + if ( ! ReadData()) { + string sOut = " ImportOff : Error in ReadData on line " + ToString( m_theScanner.GetCurrLineNbr()) ; + LOG_ERROR( GetEExLogger(), sOut.c_str()) + return false ; + } + + return true ; +} + +//---------------------------------------------------------------------------- +bool +ImportOff::ReadData( void) +{ + string sLine ; + + // Intestazione opzionale OFF + if ( ! m_theScanner.GetLine( sLine)) + return false ; + bool bOFF = ( sLine.find( "OFF") != string::npos) ; + + // Numero di vertici, di facce e di spigoli (ignorato) + if ( bOFF && ! m_theScanner.GetLine( sLine)) + return false ; + STRVECTOR vsTok ; + Tokenize( sLine, " ", vsTok) ; + if ( vsTok.size() < 3) + return false ; + int nVerts = 0, nFaces = 0 ; + if ( ! FromString( vsTok[0], nVerts) || nVerts <= 0 || + ! FromString( vsTok[1], nFaces) || nFaces <= 0) + return false ; + + // Vettore dei vertici + PNTVECTOR vVert( nVerts) ; + // lettura dei vertici + for ( int i = 0 ; i < nVerts ; ++ i) { + if ( ! m_theScanner.GetLine( sLine)) + return false ; + STRVECTOR vsTok ; + Tokenize( sLine, " ", vsTok) ; + if ( vsTok.size() < 3) + return false ; + if ( ! FromString( vsTok[0], vVert[i].x) || ! FromString( vsTok[1],vVert[i].y) || ! FromString( vsTok[2], vVert[i].z)) + return false ; + vVert[i] *= m_dScaleFactor ; + } + + // Costruttore di trimesh da insieme disordinato di triangoli + StmFromTriangleSoup StmFts ; + if ( ! StmFts.Start()) + return false ; + // lettura delle facce + for ( int i = 0 ; i < nFaces ; ++ i) { + if ( ! m_theScanner.GetLine( sLine)) + return false ; + STRVECTOR vsTok ; + Tokenize( sLine, " ", vsTok) ; + if ( vsTok.empty()) + return false ; + int nFVs = 0 ; + if ( ! FromString( vsTok[0], nFVs) || int( vsTok.size()) < nFVs + 1) + return false ; + PolyLine PL ; + for ( int j = 0 ; j < nFVs ; ++ j) { + int nV = -1 ; + if ( ! FromString( vsTok[j+1], nV) || nV < 0 || nV >= nVerts) + return false ; + PL.AddUPoint( j, vVert[nV]) ; + } + PL.Close() ; + PL.FlattenAdv( 1.) ; + PtrOwner pStm( CreateSurfTriMesh()) ; + if ( ! IsNull( pStm) && pStm->CreateByFlatContour( PL)) { + if ( ! StmFts.AddSurfTriMesh( *pStm)) + return false ; + } + } + + // Valido la superficie e calcolo le adiacenze + if ( ! StmFts.End()) + return false ; + // inserisco l'oggetto nel DB geometrico + PtrOwner pSTM( StmFts.GetSurf()) ; + int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ; + if ( nIdNew == GDB_ID_NULL) + return false ; + + return true ; +} diff --git a/ImportOff.h b/ImportOff.h new file mode 100644 index 0000000..846c10f --- /dev/null +++ b/ImportOff.h @@ -0,0 +1,37 @@ +//---------------------------------------------------------------------------- +// EgalTech 2024-2024 +//---------------------------------------------------------------------------- +// File : ImportOff.h Data : 28.11.24 Versione : 2.6k2 +// Contenuto : Dichiarazione della classe ImportOff. +// +// +// +// Modifiche : 28.11.24 DS Creazione modulo. +// +// +//---------------------------------------------------------------------------- + +#pragma once + +#include "/EgtDev/Include/EExImportOff.h" +#include "/EgtDEv/Include/EGnScanner.h" + +class Triangle3d ; + +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +class ImportOff : public IImportOff +{ + public : + virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor = 1) ; + + private : + bool ReadData( void) ; + + private : + Scanner m_theScanner ; + IGeomDB* m_pGDB ; + int m_nIdGroup ; + double m_dScaleFactor ; +} ; diff --git a/ImportPnt.cpp b/ImportPnt.cpp index b8e13b1..d8c1ede 100644 --- a/ImportPnt.cpp +++ b/ImportPnt.cpp @@ -18,7 +18,6 @@ #include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EGkGeoPoint3d.h" #include "/EgtDEv/Include/EGnScanner.h" -#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtPointerOwner.h" using namespace std ; diff --git a/ImportStl.cpp b/ImportStl.cpp index 11902cc..5e21b80 100644 --- a/ImportStl.cpp +++ b/ImportStl.cpp @@ -16,13 +16,10 @@ #include "ImportStl.h" #include "DllMain.h" #include "/EgtDev/Include/EExDllMain.h" +#include "/EgtDev/Include/EGkGeomDB.h" +#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" #include "/EgtDEv/Include/EGnScanner.h" #include "/EgtDev/Include/EGnStringUtils.h" -#include "/EgtDev/Include/EGkGeomDB.h" -#include "/EgtDev/Include/EGkSurfTriMesh.h" -#include "/EgtDev/Include/EGkStmFromTriangleSoup.h" -#include "/EgtDev/Include/SELkKeyProc.h" -#include "/EgtDev/Include/EgtKeyCodes.h" #include "/EgtDev/Include/EgtStringConverter.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include