|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F>ļ<EFBFBD>: <20><>ʽת<CABD><D7AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
|
|
|
|
|
|
// ת<><D7AA>AutoCAD<41><44>DXF<58><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
//
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2007-5-09
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#include ".\otherformat.h"
|
|
|
|
|
|
#include "afxcoll.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace NFormatReader
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
#define DXF_READ_BREAK -1
|
|
|
|
|
|
#define DXF_READ_ERROR 0
|
|
|
|
|
|
#define DXF_READ_OK 1
|
|
|
|
|
|
#define DXF_READ_ELEMENT 2 //<2F><>ȡԪ<C8A1>ض<EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
class CDxfFile :
|
|
|
|
|
|
public COtherFormat
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CDxfFile(void);
|
|
|
|
|
|
virtual ~CDxfFile(void);
|
|
|
|
|
|
|
|
|
|
|
|
int Read(LPCTSTR lpszPathName);
|
|
|
|
|
|
int Read(CFile& fr);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
int ReadSection(CFile& fr);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>
|
|
|
|
|
|
void CreatePline(void);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
int ReadSectionEntities(CFile& fr);
|
|
|
|
|
|
int ReadSectionHeader(CFile& fr);
|
|
|
|
|
|
int ReadSectionClasses(CFile& fr);
|
|
|
|
|
|
int ReadSectionBlocks(CFile& fr);
|
|
|
|
|
|
int ReadSectionTables(CFile& fr);
|
|
|
|
|
|
int ReadSectionObjects(CFile& fr);
|
|
|
|
|
|
bool IsSectionEnd(CString &cmd);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
int ReadBlock(CFile& fr);
|
|
|
|
|
|
int EndBlock(CFile& fr);
|
|
|
|
|
|
//Table
|
|
|
|
|
|
int ReadTable(CFile& fr);
|
|
|
|
|
|
int EndTable(CFile& fr);
|
|
|
|
|
|
|
|
|
|
|
|
//Ԫ<><D4AA><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
int ReadEntitieArc(CFile& fr);
|
|
|
|
|
|
int ReadEntitieCircle(CFile& fr);
|
|
|
|
|
|
int ReadEntitieLine(CFile& fr);
|
|
|
|
|
|
int ReadEntitiePline(CFile& fr);
|
|
|
|
|
|
int ReadEntitieText(CFile& fr);
|
|
|
|
|
|
int ReadEntitie3DFace(CFile& fr);
|
|
|
|
|
|
int ReadEntitiePoint(CFile& fr);
|
|
|
|
|
|
int ReadEntitieSolid(CFile& fr);
|
|
|
|
|
|
int ReadEntitieEllipse(CFile& fr);
|
|
|
|
|
|
int ReadEntitieSpline(CFile& fr);
|
|
|
|
|
|
int ReadEntitieLWPolyline(CFile& fr);
|
|
|
|
|
|
int ReadEntitieImage(CFile& fr);
|
|
|
|
|
|
int ReadEntitieMline(CFile& fr);
|
|
|
|
|
|
int ReadEntitieLeader(CFile& fr);
|
|
|
|
|
|
int ReadEntitieTrace(CFile& fr);
|
|
|
|
|
|
int ReadEntitieInsert(CFile& fr);
|
|
|
|
|
|
int ReadEntitieAttdef(CFile& fr);
|
|
|
|
|
|
int ReadEntitieAttrib(CFile& fr);
|
|
|
|
|
|
int ReadEntitieMText(CFile& fr);
|
|
|
|
|
|
int ReadEntitieHatch(CFile& fr);
|
|
|
|
|
|
|
|
|
|
|
|
//int _ReadEntitieHatch_MSegment(CFile& fr); //<2F><><EFBFBD>߶<EFBFBD>
|
|
|
|
|
|
//int _ReadEntitieHatch_Line(CFile& fr); //ֱ<><D6B1>
|
|
|
|
|
|
//int _ReadEntitieHatch_Arc(CFile& fr); //<2F><>
|
|
|
|
|
|
//int _ReadEntitieHatch_EllipseArc(CFile& fr);//<2F><>Բ<EFBFBD><D4B2>
|
|
|
|
|
|
//int _ReadEntitieHatch_Spline(CFile& fr); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
int ReadEntitieDimension(CFile& fr);
|
|
|
|
|
|
int ReadEntitieImageDef(CFile& fr);
|
|
|
|
|
|
int ReadEntitieViewPort(CFile& fr);
|
|
|
|
|
|
int ReadEntitieRay(CFile& fr);
|
|
|
|
|
|
int ReadEntitieXLine(CFile& fr);
|
|
|
|
|
|
int ReadEntitieShape(CFile& fr);
|
|
|
|
|
|
int ReadEntitieVertex(CFile& fr); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
int ReadGeneralCode(CFile& fr); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD>ζ<EFBFBD><CEB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int ReadEntitieState();
|
|
|
|
|
|
int _ReadEntities(CFile& fr); //<2F><>ȡ0<C8A1><30>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>
|
|
|
|
|
|
int ReadEntities(CFile& fr); //<2F><>ȡ0<C8A1><30>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
int SkipLine(CFile& fr); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
void InitCurrentElement(void);
|
|
|
|
|
|
virtual POSITION AddElement(void* pElement, int type);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
virtual void* GetXY(void);
|
|
|
|
|
|
|
|
|
|
|
|
CString GetFontName(CString faceName);
|
|
|
|
|
|
void SetFontName(void* pCText_Value, char* pFaceName);
|
|
|
|
|
|
|
|
|
|
|
|
CPtrList m_listBlockXY; //<2F><><EFBFBD><EFBFBD>ջ
|
|
|
|
|
|
BOOL IsBlockXY(void);
|
|
|
|
|
|
|
|
|
|
|
|
class CBlockMarkClone
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
void* m_pXy;
|
|
|
|
|
|
void* m_pMarkXy;
|
|
|
|
|
|
CString m_strMarkName;
|
|
|
|
|
|
};
|
|
|
|
|
|
CList<CBlockMarkClone, CBlockMarkClone> m_listMarkClone;
|
|
|
|
|
|
|
|
|
|
|
|
class CHeader
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CHeader(void);
|
|
|
|
|
|
CString m_strVer; //<2F>汾<EFBFBD><E6B1BE>
|
|
|
|
|
|
CPoint3D PUCSORG; //<2F><>ǰͼֽ<CDBC>ռ<EFBFBD> UCS ԭ<><D4AD>
|
|
|
|
|
|
CPoint3D PUCSXDIR; //<2F><>ǰͼֽ<CDBC>ռ<EFBFBD> UCS X <20><>
|
|
|
|
|
|
CPoint3D PUCSYDIR; //<2F><>ǰͼֽ<CDBC>ռ<EFBFBD> UCS Y <20><>
|
|
|
|
|
|
};
|
|
|
|
|
|
CHeader header;
|
|
|
|
|
|
|
|
|
|
|
|
class CReadCode
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CReadCode(void);
|
|
|
|
|
|
int Compare(LPCTSTR lpszString);
|
|
|
|
|
|
|
|
|
|
|
|
int code;
|
|
|
|
|
|
CString cmd;
|
|
|
|
|
|
};
|
|
|
|
|
|
CReadCode m_rc;
|
|
|
|
|
|
int ReadCode(CFile& fr);
|
|
|
|
|
|
|
|
|
|
|
|
//Pline
|
|
|
|
|
|
class CPolylinePar
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
CPolylinePar() {Init();};
|
|
|
|
|
|
void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_pointList.RemoveAll();
|
|
|
|
|
|
m_dStartWidth=0;
|
|
|
|
|
|
m_dEndWidth=0;
|
|
|
|
|
|
m_nSegmentType=0;
|
|
|
|
|
|
m_nSmoothType=0;
|
|
|
|
|
|
m_strEleType=_T("");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPointList m_pointList;
|
|
|
|
|
|
double m_dStartWidth;
|
|
|
|
|
|
double m_dEndWidth;
|
|
|
|
|
|
int m_nSegmentType;
|
|
|
|
|
|
int m_nSmoothType;
|
|
|
|
|
|
CString m_strEleType;
|
|
|
|
|
|
};
|
|
|
|
|
|
CPolylinePar m_polylinePar;
|
|
|
|
|
|
|
|
|
|
|
|
struct _CURRENT_ELE{
|
|
|
|
|
|
DWORD m_dwID; //<2F><>ǰԪ<C7B0>صľ<D8B5><C4BE><EFBFBD>ID<49><44>
|
|
|
|
|
|
COLORREF m_colCurrent; //<2F><>ǰԪ<C7B0>ص<EFBFBD><D8B5><EFBFBD>ɫ
|
|
|
|
|
|
BOOL m_bCurentView; //<2F><>ǰԪ<C7B0>صĿ<D8B5><C4BF><EFBFBD>״̬
|
|
|
|
|
|
CString m_strLineType; // Used LineType's Name
|
|
|
|
|
|
};
|
|
|
|
|
|
_CURRENT_ELE m_curElement;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tag_LAYER
|
|
|
|
|
|
{
|
|
|
|
|
|
char Name[512]; // Layer Name
|
|
|
|
|
|
UINT StandardFlags; // Standard flags
|
|
|
|
|
|
int Color; // Layer Color
|
|
|
|
|
|
char LineType[512]; // Line Type
|
|
|
|
|
|
} DXFLAYER, *PDXFLAYER;
|
|
|
|
|
|
|
|
|
|
|
|
CList<DXFLAYER, DXFLAYER> m_listLayer; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>Ϣ<EFBFBD><CFA2>Ϊ<EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD>͵Ȳ<CDB5><C8B2><EFBFBD>
|
|
|
|
|
|
int FindLayer(CString strLayerName, DXFLAYER& ds);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tag_LTYPE
|
|
|
|
|
|
{
|
|
|
|
|
|
char Name[512]; // Line Type Name
|
|
|
|
|
|
int StandardFlags; // Standard flags
|
|
|
|
|
|
char DescriptiveText[512]; // Descriptive Text
|
|
|
|
|
|
int ElementsNumber; // Line Elements Number
|
|
|
|
|
|
double TotalPatternLength; // Total Pattern Length
|
|
|
|
|
|
double Elements[30]; // Line Elements
|
|
|
|
|
|
} DXFLTYPE, *PDXFLTYPE;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tag_STYLE
|
|
|
|
|
|
{
|
|
|
|
|
|
char Name[512]; // Style Name
|
|
|
|
|
|
char PrimaryFontFilename[512]; // Primary Font Filename
|
|
|
|
|
|
int StandardFlags; // Standard flag values -> 4=Vertical text
|
|
|
|
|
|
int TextGenerationFlags; // Text generation flags -> 2=Text is backward 4=Text is upside down
|
|
|
|
|
|
double FixedTextHeight; // Fixed text height
|
|
|
|
|
|
double WidthFactor; // Width Factor
|
|
|
|
|
|
double Height; // Height
|
|
|
|
|
|
double ObliqueAngle; // Oblique angle
|
|
|
|
|
|
} DXFSTYLE, *PDXFSTYLE;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tag_DIMSTYLE
|
|
|
|
|
|
{
|
|
|
|
|
|
char Name[512]; // DimStyle Name
|
|
|
|
|
|
int StandardFlags; // Standard flag values
|
|
|
|
|
|
int DIMCLRD; // Dimension line & Arrow heads color
|
|
|
|
|
|
double DIMDLE; // Dimension line size after Extensionline
|
|
|
|
|
|
int DIMCLRE; // Extension line color
|
|
|
|
|
|
double DIMEXE; // Extension line size after Dimline
|
|
|
|
|
|
double DIMEXO; // Offset from origin
|
|
|
|
|
|
char DIMBLK1[512]; // 1st Arrow head
|
|
|
|
|
|
char DIMBLK2[512]; // 2nd Arrow head
|
|
|
|
|
|
double DIMASZ; // Arrow size
|
|
|
|
|
|
char DIMTXSTY[512]; // Text style
|
|
|
|
|
|
DWORD DIMTXSTYObjhandle; // Text style Object Handle
|
|
|
|
|
|
int DIMCLRT; // Text color
|
|
|
|
|
|
double DIMTXT; // Text height
|
|
|
|
|
|
int DIMTAD; // Vertical Text Placement
|
|
|
|
|
|
double DIMGAP; // Offset from dimension line
|
|
|
|
|
|
} DXFDIMSTYLE, *PDXFDIMSTYLE;
|
|
|
|
|
|
|
|
|
|
|
|
//Tables
|
|
|
|
|
|
int ReadTableVIEW(CFile &fr);
|
|
|
|
|
|
int ReadTableUCS(CFile &fr);
|
|
|
|
|
|
int ReadTableBLOCK_RECORD(CFile &fr);
|
|
|
|
|
|
int ReadTableAPPID(CFile &fr);
|
|
|
|
|
|
int ReadTableVPORT(CFile &fr);
|
|
|
|
|
|
int ReadTableSTYLE(CFile &fr);
|
|
|
|
|
|
int ReadTableDIMSTYLE(CFile &fr);
|
|
|
|
|
|
int ReadTableLAYER(CFile &fr);
|
|
|
|
|
|
int ReadTableLTYPE(CFile &fr);
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tag_DXFENTDIMENSION {
|
|
|
|
|
|
CPoint3D DefPoint3;
|
|
|
|
|
|
CPoint3D DefPoint4;
|
|
|
|
|
|
double DimRotationAngle;
|
|
|
|
|
|
CPoint3D DimLineDefPoint;
|
|
|
|
|
|
char BlockName[16];
|
|
|
|
|
|
char DimStyleName[512];
|
|
|
|
|
|
char DimText[1024];
|
|
|
|
|
|
} DXFENTDIMENSION, *PDXFENTDIMENSION;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
};
|