EgtExchange 2.6l1 :
- aggiunta importazione formato OFF (Object File Format).
This commit is contained in:
Binary file not shown.
+2
-2
@@ -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
|
||||
|
||||
@@ -232,6 +232,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="..\Include\EExImportCnc.h" />
|
||||
<ClInclude Include="..\Include\EExImportCsf.h" />
|
||||
<ClInclude Include="..\Include\EExImportDxf.h" />
|
||||
<ClInclude Include="..\Include\EExImportOff.h" />
|
||||
<ClInclude Include="..\Include\EExImportPnt.h" />
|
||||
<ClInclude Include="..\Include\EExImportStl.h" />
|
||||
<ClInclude Include="..\Include\EGkAngle.h" />
|
||||
@@ -330,6 +331,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="ImportCnc.h" />
|
||||
<ClInclude Include="ImportCsf.h" />
|
||||
<ClInclude Include="ImportDxf.h" />
|
||||
<ClInclude Include="ImportOff.h" />
|
||||
<ClInclude Include="ImportStl.h" />
|
||||
<ClInclude Include="pugiconfig.hpp" />
|
||||
<ClInclude Include="pugixml.hpp" />
|
||||
@@ -372,6 +374,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="ImportDxfEnts.cpp" />
|
||||
<ClCompile Include="ImportDxfHeader.cpp" />
|
||||
<ClCompile Include="ImportDxfTabs.cpp" />
|
||||
<ClCompile Include="ImportOff.cpp" />
|
||||
<ClCompile Include="ImportPnt.cpp" />
|
||||
<ClCompile Include="ImportStl.cpp" />
|
||||
<ClCompile Include="pugixml.cpp" />
|
||||
|
||||
@@ -375,6 +375,12 @@
|
||||
<ClInclude Include="..\Include\SELkKeyProc.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ImportOff.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EExImportOff.h">
|
||||
<Filter>File di intestazione\Include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -455,6 +461,9 @@
|
||||
<ClCompile Include="ExportThreeJS.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImportOff.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExchange.rc">
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 <fstream>
|
||||
|
||||
@@ -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 <fstream>
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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 <fstream>
|
||||
|
||||
@@ -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)
|
||||
|
||||
+155
@@ -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<IImportOff*> ( 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<ISurfTriMesh> 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<ISurfTriMesh> pSTM( StmFts.GetSurf()) ;
|
||||
int nIdNew = m_pGDB->AddGeoObj( GDB_ID_NULL, m_nIdGroup, Release( pSTM)) ;
|
||||
if ( nIdNew == GDB_ID_NULL)
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
+37
@@ -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 ;
|
||||
} ;
|
||||
@@ -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 ;
|
||||
|
||||
+2
-5
@@ -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 <fstream>
|
||||
|
||||
Reference in New Issue
Block a user