EgtExchange 1.5f3 :
- migliorata conversione testi da Codepage diverse e da codifica Unicode di Autocad.
This commit is contained in:
Binary file not shown.
@@ -212,6 +212,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="ImportDxf.cpp" />
|
||||
<ClCompile Include="ImportDxfBlocks.cpp" />
|
||||
<ClCompile Include="ImportDxfEnts.cpp" />
|
||||
<ClCompile Include="ImportDxfHeader.cpp" />
|
||||
<ClCompile Include="ImportDxfTabs.cpp" />
|
||||
<ClCompile Include="ImportStl.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
||||
@@ -74,6 +74,9 @@
|
||||
<ClCompile Include="ImportDxfBlocks.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ImportDxfHeader.cpp">
|
||||
<Filter>File di origine</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtExchange.rc">
|
||||
|
||||
+10
-1
@@ -39,6 +39,7 @@ ImportDxf::ImportDxf( void)
|
||||
m_nCurrCode = CODE_NULL ;
|
||||
m_nIdBlocksParent = GDB_ID_NULL ;
|
||||
m_nIdCurrBlock = GDB_ID_NULL ;
|
||||
m_nCodePage = 1252 ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -80,6 +81,9 @@ ImportDxf::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, double dSca
|
||||
if ( ! CreateBlocksParent())
|
||||
return false ;
|
||||
|
||||
// imposto la codepage di default ( 1252 = ANSI Latin 1)
|
||||
m_nCodePage = 1252 ;
|
||||
|
||||
// ciclo di lettura
|
||||
bool bOk = true ;
|
||||
bool bFileEnd = false ;
|
||||
@@ -88,8 +92,13 @@ ImportDxf::Import( const string& sFile, IGeomDB* pGDB, int nIdGroup, double dSca
|
||||
// leggo intestazione sezione, per avere il tipo
|
||||
bool bOkLoc = GetSectionName( sSectName, bFileEnd) ;
|
||||
if ( bOkLoc && ! bFileEnd) {
|
||||
// se sezione header
|
||||
if ( sSectName == "HEADER") {
|
||||
if ( ! ReadHeader( bFileEnd))
|
||||
bOkLoc = false ;
|
||||
}
|
||||
// se sezione tavole
|
||||
if ( sSectName == "TABLES") {
|
||||
else if ( sSectName == "TABLES") {
|
||||
if ( ! ReadTables( bFileEnd))
|
||||
bOkLoc = false ;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class ImportDxf : public IImportDxf
|
||||
bool EraseEmptyLayers( void) ;
|
||||
int GetGroupId( const std::string& sName) ;
|
||||
bool BlockReading( void) ;
|
||||
bool ReadHeader( bool& bFileEnd) ;
|
||||
bool ReadTables( bool& bFileEnd) ;
|
||||
bool GetTableName( std::string& sTabName, bool& bSectEnd, bool& bFileEnd) ;
|
||||
bool SkipTable( bool& bFileEnd) ;
|
||||
@@ -122,6 +123,7 @@ class ImportDxf : public IImportDxf
|
||||
bool m_bUnGet ;
|
||||
int m_nCurrCode ;
|
||||
std::string m_sCurrItem ;
|
||||
int m_nCodePage ;
|
||||
NameMap m_nmLayer ;
|
||||
StyleMap m_smStyle ;
|
||||
int m_nIdBlocksParent ;
|
||||
|
||||
+23
-8
@@ -27,7 +27,7 @@
|
||||
#include "/EgtDev/Include/EgkSurfTriMesh.h"
|
||||
#include "/EgtDev/Include/EgkExtText.h"
|
||||
#include "/EgtDev/Include/EGkGdbIterator.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EGnStringEncoder.h"
|
||||
#include <regex>
|
||||
|
||||
using namespace std ;
|
||||
@@ -2131,10 +2131,25 @@ ImportDxf::ReadText( bool& bFileEnd)
|
||||
bool
|
||||
ImportDxf::AdjustText( string& sText)
|
||||
{
|
||||
// per gradi, più o meno e diametro con codici Unicode
|
||||
ReplaceString( sText, "\\U+00B0", LPSTR( WtoA( L"°"))) ;
|
||||
ReplaceString( sText, "\\U+00B1", LPSTR( WtoA( L"±"))) ;
|
||||
ReplaceString( sText, "\\U+2205", LPSTR( WtoA( L"Ø"))) ;
|
||||
// se non è testo UTF-8, tento di convertirlo secondo codepage dichiarata nel DXF
|
||||
if ( ! IsTextUtf8( sText.c_str())) {
|
||||
sText = LPSTR( WtoA( LPWSTR( AtoW( sText.c_str(), m_nCodePage)))) ;
|
||||
}
|
||||
|
||||
// converto la codifica Unicode di AutoCad ( "\\U+NNNN")
|
||||
size_t nPos ;
|
||||
while ( ( nPos = sText.find( "\\U+")) != string::npos) {
|
||||
string sCode = (( sText.size() > nPos + 3) ? sText.substr( nPos+3, 4) : "") ;
|
||||
unsigned int nCode = 127 ;
|
||||
sscanf_s( sCode.c_str(), "%x", &nCode) ;
|
||||
// converto diametro in O maiuscolo barrato
|
||||
if ( nCode == 8709)
|
||||
nCode = 216 ;
|
||||
string sVal ;
|
||||
if ( ! SetCodePoint( nCode, sVal))
|
||||
sVal = "\7F" ; // carattere di errore 127
|
||||
ReplaceString( sText, "\\U+" + sCode, sVal) ;
|
||||
}
|
||||
|
||||
// se non ci sono "%%" posso uscire
|
||||
if ( sText.find( "%%") == string::npos)
|
||||
@@ -2325,11 +2340,11 @@ ImportDxf::AdjustMText( string& sText, double dTextMaxWidth, double dW)
|
||||
return false ;
|
||||
|
||||
// elimino \L \k
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[LlOoKk]"), string("")) ;
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[LlOoKk]"), string( "")) ;
|
||||
// elimino \p...; \T...;
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[pQHWFfACT][^;]*;"), string("")) ;
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[pQHWFfACT][^;]*;"), string( "")) ;
|
||||
// trasformo \Sxxx; in xxx
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[S]([^;]*);"), string("$1")) ;
|
||||
sText = tr1::regex_replace( sText, tr1::regex( "\\\\[S]([^;]*);"), string( "$1")) ;
|
||||
// traformo "\~" in ' '
|
||||
ReplaceString( sText, "\\~", " ") ;
|
||||
// trasformo "\P" in "\n"
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : ImportDxfHeader.cpp Data : 08.06.14 Versione : 1.5f3
|
||||
// Contenuto : Implementazione di ImportDxf : gestione header.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 08.06.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "ImportDxf.h"
|
||||
#include "DxfConst.h"
|
||||
#include "DllMain.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ImportDxf::ReadHeader( bool& bFileEnd)
|
||||
{
|
||||
// ciclo di lettura
|
||||
bool bOk = true ;
|
||||
bool bSectEnd = false ;
|
||||
bool bCodePage = false ;
|
||||
bFileEnd = false ;
|
||||
int nCode = CODE_NULL ;
|
||||
do {
|
||||
// leggo un Item
|
||||
nCode = ReadNextItem() ;
|
||||
if ( nCode == CODE_NULL) {
|
||||
bFileEnd = true ;
|
||||
return false ;
|
||||
}
|
||||
switch ( nCode) {
|
||||
case 0 :
|
||||
if ( m_sCurrItem == "SECTION") {
|
||||
UngetItem() ;
|
||||
bSectEnd = true ;
|
||||
}
|
||||
else if ( m_sCurrItem == "ENDSEC") {
|
||||
bSectEnd = true ;
|
||||
}
|
||||
else if ( m_sCurrItem == "EOF") {
|
||||
bSectEnd = true ;
|
||||
bFileEnd = true ;
|
||||
}
|
||||
break ;
|
||||
case 3 :
|
||||
if ( bCodePage) {
|
||||
string sCodePage = m_sCurrItem ;
|
||||
ReplaceString( sCodePage, "ANSI_", "") ;
|
||||
ReplaceString( sCodePage, "DOS", "") ;
|
||||
int nVal ;
|
||||
if ( FromString( sCodePage, nVal) && nVal >= 111 && nVal <= 28606)
|
||||
m_nCodePage = nVal ;
|
||||
}
|
||||
break ;
|
||||
case 9 :
|
||||
if ( m_sCurrItem == "$DWGCODEPAGE")
|
||||
bCodePage = true ;
|
||||
break ;
|
||||
}
|
||||
} while ( ! bSectEnd) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
Reference in New Issue
Block a user