EgtExchange 1.5h2 :
- aggiunto esportatore STL - aggiunto esportatore DXF.
This commit is contained in:
+126
-126
@@ -7,7 +7,7 @@
|
||||
//
|
||||
//
|
||||
// Modifiche : 17.04.14 DS Creazione modulo.
|
||||
//
|
||||
// 08.08.14 DS Corretti tutti i valori.
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -26,249 +26,249 @@ const unsigned char DxfColors[][3] = {
|
||||
{255, 255, 255},
|
||||
{128, 128, 128},
|
||||
{192, 192, 192},
|
||||
{255, 0, 0},
|
||||
{255, 0, 0}, // 10
|
||||
{255, 127, 127},
|
||||
{165, 0, 0},
|
||||
{165, 82, 82},
|
||||
{204, 0, 0},
|
||||
{204, 102, 102},
|
||||
{153, 0, 0},
|
||||
{153, 76, 76},
|
||||
{127, 0, 0},
|
||||
{127, 63, 63},
|
||||
{76, 0, 0},
|
||||
{76, 38, 38},
|
||||
{38, 0, 0},
|
||||
{38, 19, 19},
|
||||
{255, 63, 0},
|
||||
{255, 63, 0}, // 20
|
||||
{255, 159, 127},
|
||||
{165, 41, 0},
|
||||
{165, 103, 82},
|
||||
{204, 51, 0},
|
||||
{204, 127, 102},
|
||||
{153, 38, 0},
|
||||
{153, 95, 76},
|
||||
{127, 31, 0},
|
||||
{127, 79, 63},
|
||||
{76, 19, 0},
|
||||
{76, 47, 38},
|
||||
{38, 9, 0},
|
||||
{38, 23, 19},
|
||||
{255, 127, 0},
|
||||
{255, 127, 0}, // 30
|
||||
{255, 191, 127},
|
||||
{165, 82, 0},
|
||||
{165, 124, 82},
|
||||
{204, 102, 0},
|
||||
{204, 153, 102},
|
||||
{153, 76, 0},
|
||||
{153, 114, 76},
|
||||
{127, 63, 0},
|
||||
{127, 95, 63},
|
||||
{76, 38, 0},
|
||||
{76, 57, 38},
|
||||
{38, 19, 0},
|
||||
{38, 28, 19},
|
||||
{255, 191, 0},
|
||||
{255, 191, 0}, // 40
|
||||
{255, 223, 127},
|
||||
{165, 124, 0},
|
||||
{165, 145, 82},
|
||||
{204, 153, 0},
|
||||
{204, 178, 102},
|
||||
{153, 114, 0},
|
||||
{153, 133, 76},
|
||||
{127, 95, 0},
|
||||
{127, 111, 63},
|
||||
{76, 57, 0},
|
||||
{76, 66, 38},
|
||||
{38, 28, 0},
|
||||
{38, 33, 19},
|
||||
{255, 255, 0},
|
||||
{255, 255, 0}, // 50
|
||||
{255, 255, 127},
|
||||
{165, 165, 0},
|
||||
{165, 165, 82},
|
||||
{204, 204, 0},
|
||||
{204, 204, 102},
|
||||
{152, 152, 0},
|
||||
{152, 152, 76},
|
||||
{127, 127, 0},
|
||||
{127, 127, 63},
|
||||
{76, 76, 0},
|
||||
{76, 76, 38},
|
||||
{38, 38, 0},
|
||||
{38, 38, 19},
|
||||
{191, 255, 0},
|
||||
{191, 255, 0}, // 60
|
||||
{223, 255, 127},
|
||||
{124, 165, 0},
|
||||
{145, 165, 82},
|
||||
{153, 204, 0},
|
||||
{178, 204, 102},
|
||||
{114, 152, 0},
|
||||
{133, 152, 76},
|
||||
{95, 127, 0},
|
||||
{111, 127, 63},
|
||||
{57, 76, 0},
|
||||
{66, 76, 38},
|
||||
{28, 38, 0},
|
||||
{33, 38, 19},
|
||||
{127, 255, 0},
|
||||
{127, 255, 0}, // 70
|
||||
{191, 255, 127},
|
||||
{82, 165, 0},
|
||||
{124, 165, 82},
|
||||
{102, 204, 0},
|
||||
{153, 204, 102},
|
||||
{76, 152, 0},
|
||||
{114, 152, 76},
|
||||
{63, 127, 0},
|
||||
{95, 127, 63},
|
||||
{38, 76, 0},
|
||||
{57, 76, 38},
|
||||
{19, 38, 0},
|
||||
{28, 38, 19},
|
||||
{63, 255, 0},
|
||||
{63, 255, 0}, // 80
|
||||
{159, 255, 127},
|
||||
{41, 165, 0},
|
||||
{103, 165, 82},
|
||||
{51, 204, 0},
|
||||
{127, 204, 102},
|
||||
{38, 152, 0},
|
||||
{95, 152, 76},
|
||||
{31, 127, 0},
|
||||
{79, 127, 63},
|
||||
{19, 76, 0},
|
||||
{47, 76, 38},
|
||||
{9, 38, 0},
|
||||
{23, 38, 19},
|
||||
{0, 255, 0},
|
||||
{0, 255, 0}, // 90
|
||||
{127, 255, 127},
|
||||
{0, 165, 0},
|
||||
{82, 165, 82},
|
||||
{0, 204, 0},
|
||||
{102, 204, 102},
|
||||
{0, 152, 0},
|
||||
{76, 152, 76},
|
||||
{0, 127, 0},
|
||||
{63, 127, 63},
|
||||
{0, 76, 0},
|
||||
{38, 76, 38},
|
||||
{0, 38, 0},
|
||||
{19, 38, 19},
|
||||
{0, 255, 63},
|
||||
{0, 255, 63}, //100
|
||||
{127, 255, 159},
|
||||
{0, 165, 41},
|
||||
{82, 165, 103},
|
||||
{0, 204, 51},
|
||||
{102, 204, 127},
|
||||
{0, 152, 38},
|
||||
{76, 152, 95},
|
||||
{0, 127, 31},
|
||||
{63, 127, 79},
|
||||
{0, 76, 19},
|
||||
{38, 76, 47},
|
||||
{0, 38, 9},
|
||||
{19, 38, 23},
|
||||
{0, 255, 127},
|
||||
{0, 255, 127}, //110
|
||||
{127, 255, 191},
|
||||
{0, 165, 82},
|
||||
{82, 165, 124},
|
||||
{0, 204, 102},
|
||||
{102, 204, 153},
|
||||
{0, 152, 76},
|
||||
{76, 152, 114},
|
||||
{0, 127, 63},
|
||||
{63, 127, 95},
|
||||
{0, 76, 38},
|
||||
{38, 76, 57},
|
||||
{0, 38, 19},
|
||||
{19, 38, 28},
|
||||
{0, 255, 191},
|
||||
{0, 255, 191}, //120
|
||||
{127, 255, 223},
|
||||
{0, 165, 124},
|
||||
{82, 165, 145},
|
||||
{0, 204, 153},
|
||||
{102, 204, 178},
|
||||
{0, 152, 114},
|
||||
{76, 152, 133},
|
||||
{0, 127, 95},
|
||||
{63, 127, 111},
|
||||
{0, 76, 57},
|
||||
{38, 76, 66},
|
||||
{0, 38, 28},
|
||||
{19, 38, 33},
|
||||
{0, 255, 255},
|
||||
{0, 255, 255}, //130
|
||||
{127, 255, 255},
|
||||
{0, 165, 165},
|
||||
{82, 165, 165},
|
||||
{0, 204, 204},
|
||||
{102, 204, 204},
|
||||
{0, 152, 152},
|
||||
{76, 152, 152},
|
||||
{0, 127, 127},
|
||||
{63, 127, 127},
|
||||
{0, 76, 76},
|
||||
{38, 76, 76},
|
||||
{0, 38, 38},
|
||||
{19, 38, 38},
|
||||
{0, 191, 255},
|
||||
{0, 191, 255}, //140
|
||||
{127, 223, 255},
|
||||
{0, 124, 165},
|
||||
{82, 145, 165},
|
||||
{0, 153, 204},
|
||||
{102, 178, 204},
|
||||
{0, 114, 152},
|
||||
{76, 133, 152},
|
||||
{0, 95, 127},
|
||||
{63, 111, 127},
|
||||
{0, 57, 76},
|
||||
{38, 66, 76},
|
||||
{0, 28, 38},
|
||||
{19, 33, 38},
|
||||
{0, 127, 255},
|
||||
{0, 127, 255}, //150
|
||||
{127, 191, 255},
|
||||
{0, 82, 165},
|
||||
{82, 124, 165},
|
||||
{0, 102, 204},
|
||||
{102, 153, 204},
|
||||
{0, 76, 152},
|
||||
{76, 114, 152},
|
||||
{0, 63, 127},
|
||||
{63, 95, 127},
|
||||
{0, 38, 76},
|
||||
{38, 57, 76},
|
||||
{0, 19, 38},
|
||||
{19, 28, 38},
|
||||
{0, 63, 255},
|
||||
{0, 63, 255}, //160
|
||||
{127, 159, 255},
|
||||
{0, 41, 165},
|
||||
{82, 103, 165},
|
||||
{0, 51, 204},
|
||||
{102, 127, 204},
|
||||
{0, 38, 152},
|
||||
{76, 95, 152},
|
||||
{0, 31, 127},
|
||||
{63, 79, 127},
|
||||
{0, 19, 76},
|
||||
{38, 47, 76},
|
||||
{0, 9, 38},
|
||||
{19, 23, 38},
|
||||
{0, 0, 255},
|
||||
{0, 0, 255}, //170
|
||||
{127, 127, 255},
|
||||
{0, 0, 165},
|
||||
{82, 82, 165},
|
||||
{0, 0, 204},
|
||||
{102, 102, 204},
|
||||
{0, 0, 152},
|
||||
{76, 76, 152},
|
||||
{0, 0, 127},
|
||||
{63, 63, 127},
|
||||
{0, 0, 76},
|
||||
{38, 38, 76},
|
||||
{0, 0, 38},
|
||||
{19, 19, 38},
|
||||
{63, 0, 255},
|
||||
{63, 0, 255}, //180
|
||||
{159, 127, 255},
|
||||
{41, 0, 165},
|
||||
{103, 82, 165},
|
||||
{51, 0, 204},
|
||||
{127, 102, 204},
|
||||
{38, 0, 152},
|
||||
{95, 76, 152},
|
||||
{31, 0, 127},
|
||||
{79, 63, 127},
|
||||
{19, 0, 76},
|
||||
{47, 38, 76},
|
||||
{9, 0, 38},
|
||||
{23, 19, 38},
|
||||
{127, 0, 255},
|
||||
{127, 0, 255}, //190
|
||||
{191, 127, 255},
|
||||
{82, 0, 165},
|
||||
{124, 82, 165},
|
||||
{102, 0, 204},
|
||||
{153, 102, 204},
|
||||
{76, 0, 152},
|
||||
{114, 76, 152},
|
||||
{63, 0, 127},
|
||||
{95, 63, 127},
|
||||
{38, 0, 76},
|
||||
{57, 38, 76},
|
||||
{19, 0, 38},
|
||||
{28, 19, 38},
|
||||
{191, 0, 255},
|
||||
{191, 0, 255}, //200
|
||||
{223, 127, 255},
|
||||
{124, 0, 165},
|
||||
{145, 82, 165},
|
||||
{153, 0, 204},
|
||||
{178, 102, 204},
|
||||
{114, 0, 152},
|
||||
{133, 76, 152},
|
||||
{95, 0, 127},
|
||||
{111, 63, 127},
|
||||
{57, 0, 76},
|
||||
{66, 38, 76},
|
||||
{28, 0, 38},
|
||||
{33, 19, 38},
|
||||
{255, 0, 255},
|
||||
{255, 0, 255}, //210
|
||||
{255, 127, 255},
|
||||
{165, 0, 165},
|
||||
{165, 82, 165},
|
||||
{204, 0, 204},
|
||||
{204, 102, 204},
|
||||
{152, 0, 152},
|
||||
{152, 76, 152},
|
||||
{127, 0, 127},
|
||||
{127, 63, 127},
|
||||
{76, 0, 76},
|
||||
{76, 38, 76},
|
||||
{38, 0, 38},
|
||||
{38, 19, 38},
|
||||
{255, 0, 191},
|
||||
{255, 0, 191}, //220
|
||||
{255, 127, 223},
|
||||
{165, 0, 124},
|
||||
{165, 82, 145},
|
||||
{204, 0, 153},
|
||||
{204, 102, 178},
|
||||
{152, 0, 114},
|
||||
{152, 76, 133},
|
||||
{127, 0, 95},
|
||||
{127, 63, 111},
|
||||
{76, 0, 57},
|
||||
{76, 38, 66},
|
||||
{38, 0, 28},
|
||||
{38, 19, 33},
|
||||
{255, 0, 127},
|
||||
{255, 0, 127}, //230
|
||||
{255, 127, 191},
|
||||
{165, 0, 82},
|
||||
{165, 82, 124},
|
||||
{204, 0, 102},
|
||||
{204, 102, 153},
|
||||
{152, 0, 76},
|
||||
{152, 76, 114},
|
||||
{127, 0, 63},
|
||||
{127, 63, 95},
|
||||
{76, 0, 38},
|
||||
{76, 38, 57},
|
||||
{38, 0, 19},
|
||||
{38, 19, 28},
|
||||
{255, 0, 63},
|
||||
{255, 0, 63}, //240
|
||||
{255, 127, 159},
|
||||
{165, 0, 41},
|
||||
{165, 82, 103},
|
||||
{204, 0, 51},
|
||||
{204, 102, 127},
|
||||
{152, 0, 38},
|
||||
{152, 76, 95},
|
||||
{127, 0, 31},
|
||||
{127, 63, 79},
|
||||
{76, 0, 19},
|
||||
{76, 38, 47},
|
||||
{38, 0, 9},
|
||||
{38, 19, 23},
|
||||
{26, 26, 26},
|
||||
{51, 51, 51},
|
||||
{102, 102, 102},
|
||||
{153, 153, 153},
|
||||
{204, 204, 204},
|
||||
{51, 51, 51}, //250
|
||||
{91, 91, 91},
|
||||
{132, 132, 132},
|
||||
{173, 173, 173},
|
||||
{214, 214, 214},
|
||||
{255, 255, 255}} ;
|
||||
|
||||
+9
-1
@@ -25,6 +25,8 @@ const int ENT_HIDE = 1 ;
|
||||
// colori speciali
|
||||
const int COL_BYBLOCK = 0 ;
|
||||
const int COL_BYLAYER = 256 ;
|
||||
// colore di default
|
||||
const int COL_DEFAULT = 7 ;
|
||||
// flag per splines
|
||||
const int SPL_CLOSED = 1 ;
|
||||
const int SPL_PERIODIC = 2 ;
|
||||
@@ -40,4 +42,10 @@ const std::string FLAGS_INFO = "FLG" ;
|
||||
const std::string SCALE_INFO = "SCA" ;
|
||||
const std::string ROTAT_INFO = "ROT" ;
|
||||
const std::string VTEXT_INFO = "VEX" ;
|
||||
|
||||
// nome layer di default
|
||||
const std::string LAY_DEFAULT = "0" ;
|
||||
// tipo di linea di default
|
||||
const std::string LINETYPE_DEFAULT = "CONTINUOUS" ;
|
||||
// costanti di approssimazione per curve di Bezier e eliche
|
||||
const double BEZ_LIN_APPROX = 0.01 ;
|
||||
const double BEZ_ANG_APPROX_DEG = 5.0 ;
|
||||
|
||||
Binary file not shown.
@@ -181,6 +181,9 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Include\EExExportConst.h" />
|
||||
<ClInclude Include="..\Include\EExExportDxf.h" />
|
||||
<ClInclude Include="..\Include\EExExportStl.h" />
|
||||
<ClInclude Include="..\Include\EExImportDxf.h" />
|
||||
<ClInclude Include="..\Include\EExImportStl.h" />
|
||||
<ClInclude Include="..\Include\EGkGeoConst.h" />
|
||||
@@ -188,6 +191,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="DxfColors.h" />
|
||||
<ClInclude Include="DxfConst.h" />
|
||||
<ClInclude Include="ExcExecutor.h" />
|
||||
<ClInclude Include="ExportDxf.h" />
|
||||
<ClInclude Include="ExportStl.h" />
|
||||
<ClInclude Include="ImportDxf.h" />
|
||||
<ClInclude Include="ImportStl.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
@@ -209,6 +214,8 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExcExecutor.cpp" />
|
||||
<ClCompile Include="ExportDxf.cpp" />
|
||||
<ClCompile Include="ExportStl.cpp" />
|
||||
<ClCompile Include="ImportDxf.cpp" />
|
||||
<ClCompile Include="ImportDxfBlocks.cpp" />
|
||||
<ClCompile Include="ImportDxfEnts.cpp" />
|
||||
|
||||
@@ -48,6 +48,21 @@
|
||||
<ClInclude Include="..\Include\EGkGeoConst.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExportStl.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EExExportStl.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ExportDxf.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EExExportDxf.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Include\EExExportConst.h">
|
||||
<Filter>File di intestazione</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
@@ -77,6 +92,12 @@
|
||||
<ClCompile Include="ImportDxfHeader.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExportStl.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ExportDxf.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExchange.rc">
|
||||
|
||||
+61
-1
@@ -17,6 +17,8 @@
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnCmdParser.h"
|
||||
#include "/EgtDev/Include/EExExportStl.h"
|
||||
#include "/EgtDev/Include/EExExportDxf.h"
|
||||
#include "/EgtDev/Include/EExImportStl.h"
|
||||
#include "/EgtDev/Include/EExImportDxf.h"
|
||||
|
||||
@@ -34,7 +36,9 @@ CreateExcExecutor( void)
|
||||
ExcExecutor::ExcExecutor( void)
|
||||
{
|
||||
// assegno chiavi a funzioni di esecuzione
|
||||
m_ExecMgr.Init( 4) ;
|
||||
m_ExecMgr.Init( 8) ;
|
||||
m_ExecMgr.Insert( "EXPORTSTL", &ExcExecutor::ExecuteExportStl) ;
|
||||
m_ExecMgr.Insert( "EXPORTDXF", &ExcExecutor::ExecuteExportDxf) ;
|
||||
m_ExecMgr.Insert( "IMPORTSTL", &ExcExecutor::ExecuteImportStl) ;
|
||||
m_ExecMgr.Insert( "IMPORTDXF", &ExcExecutor::ExecuteImportDxf) ;
|
||||
}
|
||||
@@ -78,6 +82,62 @@ ExcExecutor::SetGeomDB( IGeomDB* pGdb)
|
||||
return ( m_pGDB != nullptr) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExcExecutor::ExecuteExportStl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 2 parametri : Id del gruppo, nome del file
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// recupero l'Id
|
||||
int nId = m_pParser->GetIdParam( vsParams[0]) ;
|
||||
if ( nId == CMD_ID_ERROR)
|
||||
return false ;
|
||||
// eventuale conversione di token nel nome file
|
||||
string sFile = vsParams[1] ;
|
||||
m_pParser->DirReplace( sFile) ;
|
||||
// preparo l'esportatore
|
||||
IExportStl* pExpStl = CreateExportStl() ;
|
||||
if ( pExpStl == nullptr) {
|
||||
LOG_ERROR( GetEExLogger(), "Error : CreateExportStl")
|
||||
return false ;
|
||||
}
|
||||
// eseguo l'esportazione
|
||||
bool bOk = pExpStl->Export( m_pGDB, nId, sFile) ;
|
||||
// cancello l'esportatore
|
||||
delete pExpStl ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExcExecutor::ExecuteExportDxf( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
{
|
||||
// 2 parametri : Id del gruppo, nome del file
|
||||
if ( vsParams.size() != 2)
|
||||
return false ;
|
||||
// recupero l'Id
|
||||
int nId = m_pParser->GetIdParam( vsParams[0]) ;
|
||||
if ( nId == CMD_ID_ERROR)
|
||||
return false ;
|
||||
// eventuale conversione di token nel nome file
|
||||
string sFile = vsParams[1] ;
|
||||
m_pParser->DirReplace( sFile) ;
|
||||
// preparo l'esportatore
|
||||
IExportDxf* pExpDxf = CreateExportDxf() ;
|
||||
if ( pExpDxf == nullptr) {
|
||||
LOG_ERROR( GetEExLogger(), "Error : CreateExportDxf")
|
||||
return false ;
|
||||
}
|
||||
// eseguo l'esportazione
|
||||
bool bOk = pExpDxf->Export( m_pGDB, nId, sFile) ;
|
||||
// cancello l'esportatore
|
||||
delete pExpDxf ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExcExecutor::ExecuteImportStl( const string& sCmd2, const STRVECTOR& vsParams)
|
||||
|
||||
@@ -35,6 +35,8 @@ class ExcExecutor : public IExcExecutor
|
||||
ExcExecutor( void) ;
|
||||
|
||||
private :
|
||||
bool ExecuteExportStl( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteExportDxf( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteImportStl( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
bool ExecuteImportDxf( const std::string& sCmd2, const STRVECTOR& vsParams) ;
|
||||
|
||||
|
||||
+1000
File diff suppressed because it is too large
Load Diff
+75
@@ -0,0 +1,75 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExportDxf.h Data : 07.08.14 Versione : 1.5h2
|
||||
// Contenuto : Dichiarazione della classe ExportDxf.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 07.08.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EExExportDxf.h"
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
class IGdbIterator ;
|
||||
class IGeoObj ;
|
||||
class ICurve ;
|
||||
class ICurveLine ;
|
||||
class ICurveArc ;
|
||||
class Frame3d ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ExportDxf : public IExportDxf
|
||||
{
|
||||
public :
|
||||
virtual bool SetOptions( int nFilter, int nFlag) ;
|
||||
virtual bool Export( IGeomDB* pGDB, int nId, const std::string& sFile) ;
|
||||
|
||||
public :
|
||||
ExportDxf( void) : m_nFilter( EEXFLT_DEFAULT), m_bCompoundLayer( true), m_bColorByLayer( false) {}
|
||||
|
||||
private :
|
||||
typedef std::pair<std::string,int> LAYDAT ;
|
||||
typedef std::vector<LAYDAT> LAYDATVECTOR ;
|
||||
|
||||
private :
|
||||
bool ExportHeader( IGeomDB* pGDB, int nId) ;
|
||||
bool ExportTables( IGeomDB* pGDB, int nId) ;
|
||||
bool WriteLinetypesTable( IGeomDB* pGDB, int nId) ;
|
||||
bool WriteLayersTable( IGeomDB* pGDB, int nId) ;
|
||||
bool FindLayers( const IGdbIterator& iIter, const std::string& sLay, LAYDATVECTOR& vLayDat) ;
|
||||
bool WriteLayer( const std::string& sLay, int nFlag, int nCol, const std::string& sLineType) ;
|
||||
bool ExportEntities( IGeomDB* pGDB, int nId) ;
|
||||
bool ExportGdbObject( const IGdbIterator& iIter, const std::string& sLay) ;
|
||||
bool ExportGdbGroup( const IGdbIterator& iIter, const std::string& sLay) ;
|
||||
bool ExportPoint( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportVector( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportLine( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportArc( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportCrvBezier( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportCrvCompo( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool ExportSTM( const std::string& sLay, int nCol, const IGeoObj* pGeoObj, const Frame3d& frFrame) ;
|
||||
bool WritePoint( const std::string& sLay, int nCol, const Point3d& ptP, const Vector3d& vtV, const Frame3d& frFrame) ;
|
||||
bool WriteLine( const std::string& sLay, int nCol, const ICurveLine* pLine, const Frame3d& frFrame) ;
|
||||
bool WriteCircle( const std::string& sLay, int nCol, const ICurveArc* pArc, const Frame3d& frFrame) ;
|
||||
bool WriteArc( const std::string& sLay, int nCol, const ICurveArc* pArc, const Frame3d& frFrame) ;
|
||||
bool WriteCurve3d( const std::string& sLay, int nCol, const ICurve* pCrv, const Frame3d& frFrame) ;
|
||||
bool TestFilter( int nLev, int nMode, int nStat) ;
|
||||
bool WriteItem( int nCode, int nVal) ;
|
||||
bool WriteItem( int nCode, double dVal, int nPrec = 6) ;
|
||||
bool WriteItem( int nCode, const std::string& sVal) ;
|
||||
bool ColorToACI( const Color& cCol, int& nColor) ;
|
||||
std::string UpdateLayerName( const IGdbIterator& iIter, const std::string& sLay, bool* pbExact = nullptr) ;
|
||||
|
||||
private :
|
||||
int m_nFilter ;
|
||||
bool m_bCompoundLayer ;
|
||||
bool m_bColorByLayer ;
|
||||
std::ofstream m_OutFile ;
|
||||
} ;
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExportStl.cpp Data : 07.08.14 Versione : 1.5h2
|
||||
// Contenuto : Implementazione della classe per l'esportazione in formato STL.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 07.08.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ExportStl.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDev/Include/EGkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EgnStringUtils.h"
|
||||
#include "/EgtDev/Include/EgnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <fstream>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
IExportStl*
|
||||
CreateExportStl( void)
|
||||
{
|
||||
return static_cast<IExportStl*> ( new(nothrow) ExportStl) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::SetOptions( int nFilter)
|
||||
{
|
||||
m_nFilter = nFilter ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::Export( IGeomDB* pGDB, int nId, const string& sFile)
|
||||
{
|
||||
// verifico il DB geometrico
|
||||
if ( pGDB == nullptr) {
|
||||
LOG_ERROR( GetEExLogger(), "ExportStl : Error on GeomDB")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// verifico l'Id dell'oggetto da esportare
|
||||
if ( ! pGDB->ExistsObj( nId)) {
|
||||
LOG_ERROR( GetEExLogger(), "ExportStl : Error on Id")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// apro il file di testo in scrittura
|
||||
ofstream OutFile( stringtoW( sFile), ios::out, _SH_DENYWR) ;
|
||||
if ( ! OutFile.good()) {
|
||||
LOG_ERROR( GetEExLogger(), "ExportStl : Error on open file")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( pGDB)) ;
|
||||
if ( ! ::IsValid( pIter))
|
||||
return false ;
|
||||
pIter->GoTo( nId) ;
|
||||
// esporto l'oggetto e i suoi eventuali figli
|
||||
bool bOk = ExportObject( *pIter, OutFile) ;
|
||||
|
||||
// chiudo il file
|
||||
if ( ! OutFile.good() || ! OutFile.is_open())
|
||||
bOk = false ;
|
||||
if ( OutFile.is_open())
|
||||
OutFile.close() ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::ExportObject( const IGdbIterator& iIter, ofstream& OutFile)
|
||||
{
|
||||
switch ( iIter.GetGdbType()) {
|
||||
case GDB_TY_GEO :
|
||||
{
|
||||
// recupero l'oggetto geometrico
|
||||
const IGeoObj* pGeoObj =(const_cast<IGdbIterator*>(&iIter))->GetGeoObj() ;
|
||||
if ( pGeoObj == nullptr)
|
||||
return true ;
|
||||
// recupero il riferimento globale dell'oggetto
|
||||
Frame3d frFrame ;
|
||||
if ( ! iIter.GetGlobFrame( frFrame))
|
||||
return false ;
|
||||
// recupero il livello dell'oggetto
|
||||
int nLev = GDB_LV_USER ;
|
||||
iIter.GetCalcLevel( nLev) ;
|
||||
// recupero il modo dell'oggetto
|
||||
int nMode = GDB_MD_STD ;
|
||||
iIter.GetCalcMode( nMode) ;
|
||||
// recupero lo stato dell'oggetto
|
||||
int nStat = GDB_ST_ON ;
|
||||
iIter.GetCalcStatus( nStat) ;
|
||||
// se il filtro lo abilita
|
||||
if ( TestFilter( nLev, nMode, nStat)) {
|
||||
// recupero eventuale nome
|
||||
string sName ;
|
||||
if ( ! iIter.GetName( sName))
|
||||
sName = ToString( iIter.GetId()) ;
|
||||
// emetto l'oggetto
|
||||
switch ( pGeoObj->GetType()) {
|
||||
case SRF_TRIMESH :
|
||||
if ( ! ExportSTM( sName, pGeoObj, frFrame, OutFile))
|
||||
return false ;
|
||||
break ;
|
||||
default :
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true ;
|
||||
case GDB_TY_GROUP :
|
||||
// esploro il gruppo
|
||||
return ScanGroup( iIter, OutFile) ;
|
||||
default :
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::TestFilter( int nLev, int nMode, int nStat)
|
||||
{
|
||||
if ( ( nLev == GDB_LV_USER && ( m_nFilter & EEXFLT_LEVUSER) == 0) ||
|
||||
( nLev == GDB_LV_SYSTEM && ( m_nFilter & EEXFLT_LEVSYSTEM) == 0) ||
|
||||
( nLev == GDB_LV_TEMP && ( m_nFilter & EEXFLT_LEVTEMP) == 0))
|
||||
return false ;
|
||||
if ( ( nMode == GDB_MD_STD && ( m_nFilter & EEXFLT_MODESTD) == 0) ||
|
||||
( nMode == GDB_MD_LOCKED && ( m_nFilter & EEXFLT_MODELOCKED) == 0) ||
|
||||
( nMode == GDB_MD_HIDDEN && ( m_nFilter & EEXFLT_MODEHIDDEN) == 0))
|
||||
return false ;
|
||||
if ( ( nStat == GDB_ST_OFF && ( m_nFilter & EEXFLT_STAOFF) == 0) ||
|
||||
( nStat == GDB_ST_ON && ( m_nFilter & EEXFLT_STAON) == 0) ||
|
||||
( nStat == GDB_ST_SEL && ( m_nFilter & EEXFLT_STASEL) == 0))
|
||||
return false ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::ExportSTM( const string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame,
|
||||
ofstream& OutFile)
|
||||
{
|
||||
// verifico oggetto
|
||||
const ISurfTriMesh* pSTM = GetSurfTriMesh( pGeoObj) ;
|
||||
if ( pSTM == nullptr)
|
||||
return false ;
|
||||
|
||||
try {
|
||||
// inizio oggetto
|
||||
OutFile << "solid " << sName << endl ;
|
||||
|
||||
// ciclo sui triangoli della trimesh
|
||||
Triangle3d Tria ;
|
||||
int nId = pSTM->GetFirstTriangle( Tria) ;
|
||||
while ( nId != SVT_NULL) {
|
||||
// lo porto in coordinate globali
|
||||
Tria.ToGlob( frFrame) ;
|
||||
// emetto il triangolo
|
||||
OutFile << " facet normal " << ToString( Tria.GetN().x) <<
|
||||
" " << ToString( Tria.GetN().y) <<
|
||||
" " << ToString( Tria.GetN().z) << endl ;
|
||||
OutFile << " outer loop" << endl ;
|
||||
for ( int i = 0 ; i < 3 ; ++ i) {
|
||||
OutFile << " vertex " << ToString( Tria.GetP( i).x) <<
|
||||
" " << ToString( Tria.GetP( i).y) <<
|
||||
" " << ToString( Tria.GetP( i).z) << endl ;
|
||||
}
|
||||
OutFile << " endloop" << endl ;
|
||||
OutFile << " endfacet" << endl ;
|
||||
// passo al successivo
|
||||
nId = pSTM->GetNextTriangle( nId, Tria) ;
|
||||
}
|
||||
|
||||
// termino oggetto
|
||||
OutFile << "endsolid" << endl ;
|
||||
}
|
||||
catch( ...)
|
||||
{ return false ; }
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ExportStl::ScanGroup( const IGdbIterator& iIter, ofstream& OutFile)
|
||||
{
|
||||
// creo un iteratore
|
||||
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( iIter.GetGDB())) ;
|
||||
if ( ! ::IsValid( pIter))
|
||||
return false ;
|
||||
// scandisco il gruppo
|
||||
bool bOk = true ;
|
||||
for ( bool bNext = pIter->GoToFirstInGroup( iIter) ;
|
||||
bNext ;
|
||||
bNext = pIter->GoToNext()) {
|
||||
if ( ! ExportObject( *pIter, OutFile))
|
||||
bOk = false ;
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ExportStl.h Data : 07.08.14 Versione : 1.5h2
|
||||
// Contenuto : Dichiarazione della classe ExportStl.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 07.08.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "/EgtDev/Include/EExExportStl.h"
|
||||
|
||||
class IGdbIterator ;
|
||||
class IGeoObj ;
|
||||
class Frame3d ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class ExportStl : public IExportStl
|
||||
{
|
||||
public :
|
||||
virtual bool SetOptions( int nFilter) ;
|
||||
virtual bool Export( IGeomDB* pGDB, int nId, const std::string& sFile) ;
|
||||
|
||||
public :
|
||||
ExportStl( void) : m_nFilter( EEXFLT_DEFAULT) {}
|
||||
|
||||
private :
|
||||
bool ExportObject( const IGdbIterator& iIter, std::ofstream& OutFile) ;
|
||||
bool ScanGroup( const IGdbIterator& iIter, std::ofstream& OutFile) ;
|
||||
bool TestFilter( int nLev, int nMode, int nStat) ;
|
||||
bool ExportSTM( const std::string& sName, const IGeoObj* pGeoObj, const Frame3d& frFrame, std::ofstream& OutFile) ;
|
||||
|
||||
private :
|
||||
int m_nFilter ;
|
||||
} ;
|
||||
+44
-15
@@ -20,6 +20,7 @@
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoPoint3d.h"
|
||||
#include "/EgtDev/Include/EgkGeoVector3d.h"
|
||||
#include "/EgtDev/Include/EgkCurveLine.h"
|
||||
#include "/EgtDev/Include/EgkCurveArc.h"
|
||||
#include "/EgtDev/Include/EgkCurveComposite.h"
|
||||
@@ -1272,6 +1273,7 @@ ImportDxf::ReadPoint( bool& bFileEnd)
|
||||
{
|
||||
Point3d ptP ;
|
||||
Vector3d vtExtr( 0, 0, 1) ;
|
||||
double dThick = 0 ;
|
||||
string sLayer ;
|
||||
int nSpace = ENT_MODELSPACE ;
|
||||
int nColor = COL_BYLAYER ;
|
||||
@@ -1300,6 +1302,9 @@ ImportDxf::ReadPoint( bool& bFileEnd)
|
||||
case 30 :
|
||||
FromString( m_sCurrItem, ptP.z) ;
|
||||
break ;
|
||||
case 39 :
|
||||
FromString( m_sCurrItem, dThick) ;
|
||||
break ;
|
||||
case 60 :
|
||||
FromString( m_sCurrItem, nSpace) ;
|
||||
break ;
|
||||
@@ -1328,22 +1333,39 @@ ImportDxf::ReadPoint( bool& bFileEnd)
|
||||
ValidateName( sLayer) ;
|
||||
// aggiusto per il fattore di scala
|
||||
ptP *= m_dScaleFactor ;
|
||||
dThick *= m_dScaleFactor ;
|
||||
// gestisco il riferimento del gruppo di inserimento
|
||||
if ( ! BlockReading())
|
||||
ptP.ToLoc( m_frGroup) ;
|
||||
// inserisco il punto nel DB geometrico
|
||||
// creo il punto
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
if ( ! IsValid( pGeoPnt))
|
||||
return false ;
|
||||
// setto il punto
|
||||
if ( ! pGeoPnt->Set( ptP))
|
||||
return false ;
|
||||
// inserisco il punto nel DB
|
||||
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, GetGroupId( sLayer), Release( pGeoPnt)) ;
|
||||
// inserisco l'entità nel DB geometrico
|
||||
PtrOwner<IGeoObj> pGeoObj ; ;
|
||||
if ( fabs( dThick) < EPS_SMALL) {
|
||||
// creo il punto
|
||||
PtrOwner<IGeoPoint3d> pGeoPnt( CreateGeoPoint3d()) ;
|
||||
if ( ! IsValid( pGeoPnt))
|
||||
return false ;
|
||||
// setto il punto
|
||||
if ( ! pGeoPnt->Set( ptP))
|
||||
return false ;
|
||||
// lo passo all'oggetto geometrico generico
|
||||
pGeoObj.Set( Release( pGeoPnt)) ;
|
||||
}
|
||||
else {
|
||||
// creo il vettore con punto base
|
||||
PtrOwner<IGeoVector3d> pGeoVect( CreateGeoVector3d()) ;
|
||||
if ( ! IsValid( pGeoVect))
|
||||
return false ;
|
||||
// setto il punto
|
||||
if ( ! pGeoVect->Set( dThick * vtExtr, ptP))
|
||||
return false ;
|
||||
// lo passo all'oggetto geometrico generico
|
||||
pGeoObj.Set( Release( pGeoVect)) ;
|
||||
}
|
||||
// inserisco l'entità nel DB
|
||||
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, GetGroupId( sLayer), Release( pGeoObj)) ;
|
||||
if ( nId == GDB_ID_NULL)
|
||||
return false ;
|
||||
// eventuale assegnazione del colore
|
||||
// eventuale assegnazione del colore
|
||||
if ( ! SetColor( nId, nColor, sLayer))
|
||||
return false ;
|
||||
return true ;
|
||||
@@ -1453,7 +1475,11 @@ ImportDxf::CompletePolyLine( const string& sLayer, int nColor, int nFlag, bool b
|
||||
if ( sEntName == "VERTEX") {
|
||||
if ( ! ReadPolyLineVertex( VertTmp, bFileEnd))
|
||||
bOkLoc = false ;
|
||||
if ( ! bIs3d)
|
||||
// se polilinea 3d non sono ammessi archi (bulge = 0)
|
||||
if ( bIs3d)
|
||||
VertTmp.first = 0 ;
|
||||
// altrimenti polilinea 2d quindi z = 0
|
||||
else
|
||||
VertTmp.second.z = 0 ;
|
||||
vVert.push_back( VertTmp) ;
|
||||
nNumVert ++ ;
|
||||
@@ -1481,6 +1507,9 @@ ImportDxf::CompletePolyLine( const string& sLayer, int nColor, int nFlag, bool b
|
||||
// se entità da saltare, esco
|
||||
if ( ! bToSave)
|
||||
return true ;
|
||||
// se un solo vertice, esco
|
||||
if ( nNumVert <= 1)
|
||||
return true ;
|
||||
// Se chiusa, aggiungo un punto uguale al primo in coda
|
||||
if ( nFlag & 1) {
|
||||
vVert.push_back( vVert[0]) ;
|
||||
@@ -2170,7 +2199,7 @@ ImportDxf::ReadSpline( bool& bFileEnd)
|
||||
for ( int i = 0 ; i < int( vIntPnt.size()) ; ++ i)
|
||||
crvByInterp.AddPoint( vIntPnt[i]) ;
|
||||
crvByInterp.End() ;
|
||||
PtrOwner<ICurve> pCrv( crvByInterp.GetCurve( CurveByInterp::BESSEL, CurveByInterp::CUBIC_BEZIER)) ;
|
||||
PtrOwner<ICurve> pCrv( crvByInterp.GetCurve( CurveByInterp::BESSEL, CurveByInterp::CUBIC_BEZIERS)) ;
|
||||
if ( ! ::IsValid( pCrv))
|
||||
return false ;
|
||||
// Inserisco la curva nel DB
|
||||
@@ -2208,8 +2237,8 @@ ImportDxf::ReadSpline( bool& bFileEnd)
|
||||
if ( ! NurbsCurveCanonicalize( cnData))
|
||||
return false ;
|
||||
// creo la curva equivalente alla Nurbs
|
||||
ICurve* pCrv ;
|
||||
if ( ! NurbsToBezierCurve( cnData, pCrv))
|
||||
ICurve* pCrv = NurbsToBezierCurve( cnData) ;
|
||||
if ( pCrv == nullptr)
|
||||
return false ;
|
||||
// Inserisco la curva composita nel DB
|
||||
int nId = m_pGDB->AddGeoObj( GDB_ID_NULL, GetGroupId( sLayer), pCrv) ;
|
||||
|
||||
@@ -54,6 +54,7 @@ ImportDxf::ReadHeader( bool& bFileEnd)
|
||||
case 3 :
|
||||
if ( bCodePage) {
|
||||
string sCodePage = m_sCurrItem ;
|
||||
ToUpper( sCodePage) ;
|
||||
ReplaceString( sCodePage, "ANSI_", "") ;
|
||||
ReplaceString( sCodePage, "DOS", "") ;
|
||||
int nVal ;
|
||||
|
||||
Reference in New Issue
Block a user