DwgReader.h
上传用户:hell82222
上传日期:2013-12-19
资源大小:1872k
文件大小:8k
- #if !defined(AFX_DWGREADER_H__FCBEDD8A_A5E2_4614_A97E_65CF2974943D__INCLUDED_)
- #define AFX_DWGREADER_H__FCBEDD8A_A5E2_4614_A97E_65CF2974943D__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "Reader.h"
- #include "KmMatch.h"
- #include "ProgressInfo.h"
- #include "KmgConverter.h"
- #include "CommandInfo.h"
- #include "Vector.h"
- #include "KmObject.h"
- #include "KmDim.h"
- #define DATAVESSEL_BLOCKDEF (1)
- #define DATAVESSEL_DATABASE (2)
- #define DATAVESSEL_MODELSPACE (3)
- #define DATAVESSEL_TEMPVESSEL (4)
- typedef enum
- {
- AD_WORD,
- AD_BLANKSPACE,
- AD_END_OF_PARAGRAPH
- } AD_MTEXT_WORD_TYPE;
- typedef struct
- {
- char text[500];
- double width;
- int type;
- double height;
- } AD_MTEXT_WORD, *PAD_MTEXT_WORD;
- class CDwgReader : public CReader
- {
- public:
- CDwgReader(CProgressInfo* pProgress,CCommandInfo* pCommand,CKmgConverter* pConverter);
- virtual ~CDwgReader();
- static void fn_loadometer(short spercent);
- private:
- CProgressInfo* m_pProgress;
- CCommandInfo* m_pCommand;
- CKmgConverter* m_pConverter;
- PAD_DWGHDR adhd; //adhd -- header structure
- PAD_ENT_HDR adenhd; //adenhd -- entity header structure
- PAD_ENT aden; //aden -- entity body structure
- PAD_OBJ_HDR adobhd;
- PAD_OBJ adob;
- PAD_TB adtb; //adtb -- union containing the various table structures
- PAD_XD adxd; //adxd -- extended data structure
- CArray<ADPLOTSTYLETABLE*,ADPLOTSTYLETABLE*>m_aPlotStyleTable;
- int m_iCurPlotStyleTable;
- int m_iModelPlotStyleTable;
- short sReturnValue;
- #ifdef _BAOJI_//宝鸡
- double m_dTotalTxtHeight;
- DWORD m_dwTextcount;
- #endif
- private://实体属性
- // CArray<int,int> m_alwidth;//线宽
- CArray<int,int> m_aColor;//颜色
- CMatchList1 m_altype;//线形
- CMatchList2 m_alayer;//层
- CMatchList2 m_ablock;//块定义
- CMatchList2 m_adimstyle;//尺寸样式
- CMatchList3 m_apaper;//纸区空间
- CMatchList4 m_amltype;//平行线样式
- CMatchList5 m_ashape;//形
- CMatchList6 m_aplot;//打印样式
- private://系统变量
- int m_icolorbyback;//颜色随底色的颜色值
- int m_ilinewidthdefault;//默认线宽
- double m_dpointtocircleradius;//点转换为圆的半径
- double m_dconstrulinelength;//结构线的长度
- int m_ddimconvmode;//尺寸转换为块
- // int m_dmtextconvmode;//多行文字转换方式
- int m_dproxyconvmode;//代理实体转换方式
- int m_dsplineconvmode;//样条转换方式
- int m_dviewcutconvmode;//视口裁减方式
- double m_dlinespacemodify;//行距校正系数
- // double m_dtextposmodify;//字的位置校正系数
- // double m_dtoltexthight;//默认字高-主要用于形位公差
- double m_dtoltextwidthf;//默认字宽比字高
- double m_dtoltextspacef;//默认字间距比字高
- int m_dplotstyleconvmode;//打印样式转换模式
- int m_ddimstyleconvmode;
- CString m_strDimStyleFullName;
-
- AD_OBJHANDLE m_hFirstDimStyle;
- public:
- void RGBtoHSV(double r,double g,double b,double *h,double *s,double *v);
- void UsePlotStyle(int acicolor,int& ilwidth,int& icolor,int& iltype,double& dlscale,AD_OBJHANDLE plotstyleobjhandle,unsigned char flag=0);
- BOOL BeginConvert(); //转换开始的初始化.
- BOOL Parse(); //分析文件的主函数.
- BOOL Parse(AD_DB_HANDLE dwghandle); //分析文件的主函数.
- BOOL EndConvert(); //结束转换.
- BOOL allocateadptrs(void); //为DWG读取包申请内存空间.
- void freeadptrs(void); //为DWG读取包释放内存空间.
- private:
- BOOL processfile(AD_DB_HANDLE dwghandle,BOOL bPaper=TRUE);//入口
- BOOL processheader(AD_DB_HANDLE dwghandle);
- BOOL processsysvar(AD_DB_HANDLE dwghandle);
- BOOL processcolor(AD_DB_HANDLE dwghandle);
- BOOL processlinetype(AD_DB_HANDLE dwghandle);
- BOOL processlinewidth(AD_DB_HANDLE dwghandle);
- BOOL processplotstyle(AD_DB_HANDLE dwghandle);
- BOOL processlayer(AD_DB_HANDLE dwghandle);
- BOOL processlinescale(AD_DB_HANDLE dwghandle);
- BOOL processblockdefine(AD_DB_HANDLE dwghandle);
- BOOL processblockdefineobjs(AD_DB_HANDLE dwghandle,BOOL bref=FALSE);
- BOOL processobject(AD_DB_HANDLE dwghandle);
- BOOL processentity(AD_DB_HANDLE dwghandle);//直接使用PAD_ENT_HDR adenhd;和PAD_ENT aden;
- BOOL processmodalentity(AD_DB_HANDLE dwghandle,CStringArray *pstrSpaceNames,CStringArray *pstrSpaceFiles);
- BOOL processpaperentity(AD_DB_HANDLE dwghandle,CStringArray *pstrSpaceNames,CStringArray *pstrSpaceFiles);
- BOOL processshapefile(AD_DB_HANDLE dwghandle);
- BOOL processcodepage(AD_DB_HANDLE dwghandle);
- BOOL processdimstyle(AD_DB_HANDLE dwghandle);
- BOOL processnouseblock(AD_DB_HANDLE dwghandle);
- private:
- BOOL processobject_mlinestyle(AD_DB_HANDLE dwghandle);
- BOOL processobject_layout(AD_DB_HANDLE dwghandle);
- private:
- BOOL processentity_enthead(AD_DB_HANDLE dwghandle);
- BOOL processentity_shape(AD_DB_HANDLE dwghandle);
- BOOL processentity_line(AD_DB_HANDLE dwghandle);
- BOOL processentity_3dline(AD_DB_HANDLE dwghandle);
- BOOL processentity_point(AD_DB_HANDLE dwghandle);
- BOOL processentity_circle(AD_DB_HANDLE dwghandle);
- BOOL processentity_ellipse(AD_DB_HANDLE dwghandle);
- BOOL processentity_arc(AD_DB_HANDLE dwghandle);
- BOOL processentity_xline(AD_DB_HANDLE dwghandle);
- BOOL processentity_3dface(AD_DB_HANDLE dwghandle);
- BOOL processentity_ray(AD_DB_HANDLE dwghandle);
- BOOL processentity_spline(AD_DB_HANDLE dwghandle);
- BOOL processentity_insert(AD_DB_HANDLE dwghandle);
- BOOL processentity_block(AD_DB_HANDLE dwghandle);
- BOOL processentity_mline(AD_DB_HANDLE dwghandle);
- BOOL processentity_solid(AD_DB_HANDLE dwghandle);
- BOOL processentity_acis(AD_DB_HANDLE dwghandle);
- BOOL processentity_trace(AD_DB_HANDLE dwghandle);
- BOOL processentity_viewport(AD_DB_HANDLE dwghandle);
- BOOL processentity_text(AD_DB_HANDLE dwghandle);
- BOOL processentity_attdef(AD_DB_HANDLE dwghandle);
- BOOL processentity_attrib(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim(AD_DB_HANDLE dwghandle);
- BOOL processentity_mtext(AD_DB_HANDLE dwghandle);
- BOOL processentity_atext(AD_DB_HANDLE dwghandle);
- BOOL processentity_rtext(AD_DB_HANDLE dwghandle);
- BOOL processentity_polyline(AD_DB_HANDLE dwghandle,AD_VMADDR list);
- BOOL processentity_lwpline(AD_DB_HANDLE dwghandle);//polyline2
- BOOL processentity_leader(AD_DB_HANDLE dwghandle);
- BOOL processentity_tolerance(AD_DB_HANDLE dwghandle);
- void processentity_tol_blob(int code,short datatype,double &tolhight);
- BOOL processentity_hatch(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_head(AD_DB_HANDLE dwghandle,KmObject* obj);
- BOOL processentity_dim_tail(AD_DB_HANDLE dwghandle,KmObject* obj);
- void processentity_dim_blob(AD_DB_HANDLE dwghandle,KmDimStlAcsMgr* &pDimStlAccMgr,int code,short datatype);
- BOOL processentity_dim_rotated(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_aligned(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_angular(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_diameter(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_radius(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_angular3pt(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_ordinate(AD_DB_HANDLE dwghandle);
- BOOL processentity_dim_blockref(AD_DB_HANDLE dwghandle);
- private:
- BOOL preprocess_Convertxref(AD_DB_HANDLE dwghandle);
- BOOL preprocess_Convertmtext(AD_DB_HANDLE dbh,int mode);
- short preprocess_ExtractMTextString(PAD_MTEXT mtext, unsigned char **cptr);
- void preprocess_AddWord(AD_DB_HANDLE dbh,PAD_MTEXT_WORD pWord,PAD_TDATA pTData,PAD_SHPTB pShp,PAD_BLOB_CTRL bcptr,int type,double height);
- int preprocess_BuildWordList(AD_DB_HANDLE dbh, PAD_ENT pEnt, AD_VMADDR blob);
- void preprocess_BreakParagraph(AD_DB_HANDLE dbh,PAD_ENT pEnt,AD_VMADDR blob,int wordCount,AD_VMADDR entList,PAD_ENT_HDR pHdr);
- BOOL preprocess_Convertproxy(AD_DB_HANDLE handle,int mode);
- void calculate_3dbulgelines(CArray<CVector*,CVector*>&avectors);
- BOOL calculate_BackView();
-
- void calculate_rotatealix(double &x,double &y,double a);
- BOOL CallSpaceConvDlg(HWND hWnd,CStringArray &m_strSpaceNames,CStringArray &m_strSpaceFiles,int &iCur);
- };
- #endif // !defined(AFX_DWGREADER_H__FCBEDD8A_A5E2_4614_A97E_65CF2974943D__INCLUDED_)