Files
EgtExchange/ImportDxf.h
T
Dario Sassi 8cb371f81c EgtExchange :
- piccoli adattamenti.
2015-06-06 17:51:26 +00:00

136 lines
5.5 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : ImportDxf.h Data : 19.05.14 Versione : 1.5e4
// Contenuto : Dichiarazione della classe ImportDxf.
//
//
//
// Modifiche : 16.04.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "/EgtDev/Include/EExImportDxf.h"
#include "/EgtDEv/Include/EGnScanner.h"
#include "/EgtDev/Include/EgkGeoCollection.h"
#include <unordered_map>
//----------------------------------------------------------------------------
struct InsertData
{
std::string sName ;
std::string sLayer ;
Point3d ptP ;
Vector3d vtExtr ;
double dRotAngDeg ;
Vector3d vtScale ;
InsertData( void) : ptP(), vtExtr( 0, 0, 1), dRotAngDeg( 0), vtScale( 1, 1, 1) {}
} ;
//----------------------------------------------------------------------------
class ImportDxf : public IImportDxf
{
public :
virtual bool Import( const std::string& sFile, IGeomDB* pGDB, int nIdGroup, double dScaleFactor = 1) ;
public :
ImportDxf( void) ;
private :
int ReadNextItem( void) ;
void UngetItem( void) ;
bool GetSectionName( std::string& sSectName, bool& bFileEnd) ;
bool SkipSection( bool& bFileEnd) ;
bool CreateBlocksParent( void) ;
bool EraseBlocksParent( void) ;
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) ;
bool ReadLayerTable( bool& bFileEnd) ;
bool ReadLayer( bool& bFileEnd) ;
int GetLayerId( const std::string& sName) ;
bool ReadStyleTable( bool& bFileEnd) ;
bool ReadStyle( bool& bFileEnd) ;
bool GetStyleData( const std::string& sStyle, std::string& sFont, double& dH, double& dRat) ;
bool ReadBlocks( bool& bFileEnd) ;
bool ReadBlock( bool& bFileEnd) ;
bool ReadEndBlock( bool& bFileEnd) ;
int GetBlockId( const std::string& sName) ;
bool SolveBlockReferences( void) ;
bool SaveInsertInfo( int nId, const InsertData& insData) ;
bool LoadInsertInfo( int nId, InsertData& insData) ;
bool InsertBlockInBlock( int nIdDest, int nIdIns, const InsertData& insData) ;
bool ReadEntities( bool& bFileEnd) ;
bool ReadOneEntity( std::string& sEntName, bool& bOk, bool& bFileEnd) ;
bool GetEntityName( std::string& sEntName, bool& bSectEnd, bool& bFileEnd) ;
bool SkipEntity( bool& bFileEnd) ;
bool SetColor( int nId, int nColor, const std::string& sLayer) ;
bool SetColorForInsert( int nId, int nIdS, const std::string& sLayer) ;
bool ColorFromACI( int nColor, Color& cCol) ;
bool Read3dFace( bool& bFileEnd) ;
bool ReadArc( bool& bFileEnd) ;
bool ReadCircle( bool& bFileEnd) ;
bool ReadEllipse( bool& bFileEnd) ;
bool ReadInsert( bool& bFileEnd) ;
bool ReadInsertAttribs( bool bSave, int nGroupId, bool& bFileEnd) ;
bool ReadLine( bool& bFileEnd) ;
bool ReadRayXline( bool bIsRay, bool& bFileEnd) ;
bool ReadLwPolyLine( bool& bFileEnd) ;
bool ReadPoint( bool& bFileEnd) ;
bool ReadPolyLine( bool& bFileEnd) ;
bool CompletePolyLine( const std::string& sLayer, int nColor, int nFlag, bool bToSave,
double dElevation, double dThick, const Vector3d& vtExtr, bool& bFileEnd) ;
bool ReadPolyLineVertex( Point3d& ptP, double& dBulge, bool& bFileEnd) ;
bool CompletePolygonMesh( const std::string& sLayer, int nColor, int nFlag, bool bToSave,
double dElevation, const Vector3d& vtExtr, int nNumVertM, int nNumVertN, bool& bFileEnd) ;
bool ReadPolygonMeshVertex( Point3d& ptP, bool& bFileEnd) ;
bool CompletePolyfaceMesh( const std::string& sLayer, int nColor, int nFlag, bool bToSave,
double dElevation, const Vector3d& vtExtr, bool& bFileEnd) ;
bool ReadPolyfaceMeshVertex( int& nStat, Point3d& ptP, int nIdVT1[3], int nIdVT2[3], bool& bFileEnd) ;
bool ReadSolid( bool& bFileEnd) ;
bool ReadSpline( bool& bFileEnd) ;
bool ReadText( int nGroupId, bool& bFileEnd) ;
bool AdjustText( std::string& sText) ;
bool ReadMText( bool& bFileEnd) ;
bool AdjustMText( std::string& sText, double dTextMaxWidth, double dW) ;
private :
typedef std::unordered_map<std::string, int> NameMap ;
private :
struct Style {
std::string sFont ;
double dH ;
double dRat ;
Style( std::string sFont_, double dH_, double dRat_)
: sFont( sFont_), dH( dH_), dRat( dRat_) {}
} ;
typedef std::unordered_map<std::string, Style> StyleMap ;
private :
IGeomDB* m_pGDB ;
int m_nIdGroup ;
double m_dScaleFactor ;
Frame3d m_frGroup ;
Scanner m_theScanner ;
bool m_bUnGet ;
int m_nCurrCode ;
std::string m_sCurrItem ;
int m_nCodePage ;
NameMap m_nmLayer ;
StyleMap m_smStyle ;
int m_nIdBlocksParent ;
int m_nIdCurrBlock ;
int m_nNumNotBokInCurrBlock ;
NameMap m_nmBlock ;
} ;