aaa1.cpp
资源名称:jianmu.rar [点击查看]
上传用户:szhjsaaa
上传日期:2014-09-18
资源大小:2546k
文件大小:21k
源码类别:
CAD
开发平台:
Visual C++
- // aaa1.cpp : Initialization functions
- #include "StdAfx.h"
- #include "StdArx.h"
- #include "resource.h"
- #include <afxdllx.h>
- #include "math.h"
- //#include <aced.h>
- //#include <rxregsvc.h>
- HINSTANCE _hdllInstance =NULL ;
- // This command registers an ARX command.
- void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
- const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal = -1);
- // NOTE: DO NOT edit the following lines.
- //{{AFX_ARX_MSG
- void InitApplication();
- void UnloadApplication();
- //}}AFX_ARX_MSG
- // NOTE: DO NOT edit the following lines.
- //{{AFX_ARX_ADDIN_FUNCS
- //}}AFX_ARX_ADDIN_FUNCS
- void DrawFunction();
- ////////////////////////////////////////////////////////////////////////////
- //
- // Define the sole extension module object.
- AC_IMPLEMENT_EXTENSION_MODULE(Aaa1DLL);
- // Now you can use the CAcModuleRecourceOverride class in
- // your application to switch to the correct resource instance.
- // Please see the ObjectARX Documentation for more details
- /////////////////////////////////////////////////////////////////////////////
- // DLL Entry Point
- extern "C"
- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
- {
- if (dwReason == DLL_PROCESS_ATTACH)
- {
- _hdllInstance = hInstance;
- // Extension DLL one time initialization
- Aaa1DLL.AttachInstance(hInstance);
- InitAcUiDLL();
- } else if (dwReason == DLL_PROCESS_DETACH) {
- // Terminate the library before destructors are called
- Aaa1DLL.DetachInstance();
- }
- return TRUE; // ok
- }
- /////////////////////////////////////////////////////////////////////////////
- // ObjectARX EntryPoint
- extern "C" AcRx::AppRetCode
- acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
- {
- switch (msg) {
- case AcRx::kInitAppMsg:
- // Comment out the following line if your
- // application should be locked into memory
- acrxDynamicLinker->unlockApplication(pkt);
- acrxDynamicLinker->registerAppMDIAware(pkt);
- InitApplication();
- break;
- case AcRx::kUnloadAppMsg:
- UnloadApplication();
- break;
- }
- return AcRx::kRetOK;
- }
- // Init this application. Register your
- // commands, reactors...
- void InitApplication()
- {
- // NOTE: DO NOT edit the following lines.
- //{{AFX_ARX_INIT
- //}}AFX_ARX_INIT
- // TODO: add your initialization functions
- acedRegCmds->addCommand("HELLOWORLD_COMMANDS",
- "Draw","Draw",ACRX_CMD_TRANSPARENT,DrawFunction);
- acutPrintf("可以执行命令:draw");
- }
- // Unload this application. Unregister all objects
- // registered in InitApplication.
- void UnloadApplication()
- {
- // NOTE: DO NOT edit the following lines.
- //{{AFX_ARX_EXIT
- //}}AFX_ARX_EXIT
- // TODO: clean up your application
- acedRegCmds->removeGroup("HELLOWORLD_COMMANDS");
- }
- // This functions registers an ARX command.
- // It can be used to read the localized command name
- // from a string table stored in the resources.
- void AddCommand(const char* cmdGroup, const char* cmdInt, const char* cmdLoc,
- const int cmdFlags, const AcRxFunctionPtr cmdProc, const int idLocal)
- {
- char cmdLocRes[65];
- // If idLocal is not -1, it's treated as an ID for
- // a string stored in the resources.
- if (idLocal != -1) {
- // Load strings from the string table and register the command.
- ::LoadString(_hdllInstance, idLocal, cmdLocRes, 64);
- acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLocRes, cmdFlags, cmdProc);
- } else
- // idLocal is -1, so the 'hard coded'
- // localized function name is used.
- acedRegCmds->addCommand(cmdGroup, cmdInt, cmdLoc, cmdFlags, cmdProc);
- }
- #define copypt(d,s) d[X]=s[X];d[Y]=s[Y];d[Z]=s[Z];
- ads_point ncspt[3];//声明建立新坐标系的三个点变量
- double pi=3.14159265358979;
- int count=0;
- struct myread
- {
- double onlyid; //控制点号
- double nameind; //巷道名称索引号
- double x;
- double y;
- double z;
- float ld; //点至左邦的距离
- float rd; //点至右邦的距离
- float bd; //点至底板的距离
- int ptype; //巷道类型
- }buffer[50];//存放测量原始数据
- struct mytag //建立巷道属性表结构
- {
- double nameind; //索引号
- char name[50]; //巷道名称
- float enddist;
- float endhigh;
- float twidth;
- float bwidth;
- float wallhigh;
- int tunneltype;//巷道类型
- }temtag; //temtag结构存放巷道属性值
- //计算三点的圆心坐标放入cp点,cp[Z]=axdot[i+1][Z]-axdot[i][Z]存放两相邻点之间的高差
- void calcp(ads_point pt1,ads_point pt2,ads_point pt3,ads_point cp1)
- {
- double A1,A2,B1,B2,C1,C2;
- A1=pt1[X]-pt2[X];
- A2=pt3[X]-pt2[X];
- B1=pt1[Y]-pt2[Y];
- B2=pt3[Y]-pt2[Y];
- C1=(pt1[X]*pt1[X]+pt1[Y]*pt1[Y]-pt2[X]*pt2[X]-pt2[Y]*pt2[Y])/2;
- C2=(pt3[X]*pt3[X]+pt3[Y]*pt3[Y]-pt2[X]*pt2[X]-pt2[Y]*pt2[Y])/2;
- cp1[Y]=(C2-A2*C1/A1)/(B2-A2*B1/A1);
- cp1[X]=(C1-B1*cp1[Y])/A1;
- // cp1[X]=(C1-B1*(C2-A2*C1/A1)/(B2-A2*B1/A1))/A1;
- cp1[Z]=pt1[Z];
- // R1=sqrt((cp1[X]-pt1[X])*(cp1[X]-pt1[X])+(cp1[Y]-pt1[Y])*(cp1[Y]-pt1[Y]));
- return;
- }//end calcp
- double ang(ads_point cp2,ads_point pt4)
- {
- double or;//方位角变量
- int rc2=0;
- double e,f,g;
- e=pt4[Y]-cp2[Y];
- f=pt4[X]-cp2[X];
- g=atan(e/f);
- if(g<0)
- g=-atan(e/f);
- if(e>0)
- {
- if(f>0)
- rc2=1;
- if(f<0)
- rc2=2;
- }
- if(e<0)
- {
- if(f<0)
- rc2=3;
- if(f>0)
- rc2=4;
- }
- switch(rc2)
- {
- case 0:
- break;
- case 1:
- or=g;
- break;
- case 2:
- or=pi-g;
- break;
- case 3:
- or=pi+g;
- break;
- case 4:
- or=2*pi-g;
- break;
- }
- if(e==0)
- {
- if(f>0)
- or=0.0;
- if(f<0)
- or=pi;
- }
- if(f==0)
- {
- if(e>0)
- or=pi/2;
- if(e<0)
- or=pi+pi/2;
- }
- return or;
- }//end ang()
- //标记巷道名称
- void lable(ads_point pt1,ads_point pt2,char tagtex[50])
- {
- ads_point tempt={5.0,2.50,0}; //文本标注的左下基点
- ads_point pt3;
- pt3[X]=pt1[X]-(pt2[Y]-pt1[Y]);
- pt3[Y]=pt1[Y]+(pt2[X]-pt1[X]);
- pt3[Z]=pt1[Z];
- //三点法建立新坐标系
- acedCommand(RTSTR,"ucs",RTSTR,"n",RTSTR,"3",RT3DPOINT,pt1,
- RT3DPOINT,pt2,RT3DPOINT,pt3,RTNONE);
- //在新坐标系中标注文本
- acedCommand(RTSTR,"text",RTSTR,"j",RTSTR,"bl",RT3DPOINT,tempt,
- RTSTR,"2",RTANG,0.0,RTSTR,tagtex,RTNONE);
- //恢复到世界坐标系
- acedCommand(RTSTR,"ucs",RTSTR,"w",RTNONE);
- }//end lable
- // 计算巷道中轴线点坐标,建立巷道图层,画三维巷道
- void rbcirc()
- {
- int i=0,j=0;
- int rc=0,rc1=0;
- ads_name ent1,ent2;
- //把测点坐标转换成巷道中轴线ads_point点坐标
- ads_point *axdot=new ads_point[count+1];
- double a,b,ex,ey,c,l,d1,d2,elx,ely,etx,ety,ez;
- float d;
- for(i=0;i<count-1;i++)
- {
- a=buffer[i+1].x-buffer[i].x;
- b=buffer[i+1].y-buffer[i].y;
- c=sqrt(a*a+b*b);
- d=(buffer[i].ld-buffer[i].rd)/2;
- ex=b*d/c;
- ey=a*d/c;
- axdot[i][X]=buffer[i].x-ex;
- axdot[i][Y]=buffer[i].y+ey;
- axdot[i][Z]=buffer[i].z-buffer[i].bd;
- }
- //计算最后一个导线点的中轴点
- a=buffer[count-2].x-buffer[count-1].x;
- b=buffer[count-2].y-buffer[count-1].y;
- c=sqrt(a*a+b*b);
- d=(buffer[count-1].rd-buffer[count-1].ld)/2;
- ex=b*d/c;
- ey=a*d/c;
- axdot[count-1][X]=buffer[count-1].x-ex;
- axdot[count-1][Y]=buffer[count-1].y+ey;
- axdot[count-1][Z]=buffer[count-1].z-buffer[count-1].bd;
- //计算巷道掌头的中轴点
- a=axdot[count-1][X]-axdot[count-2][X];
- b=axdot[count-1][Y]-axdot[count-2][Y];
- c=sqrt(a*a+b*b);
- l=temtag.enddist;
- axdot[count][X]=axdot[count-1][X]+a*l/c;
- axdot[count][Y]=axdot[count-1][Y]+b*l/c;
- axdot[count][Z]=temtag.endhigh;
- for(i=0;i<count;i++)
- acutPrintf(" %lf, %lf, %fn",axdot[i][X],axdot[i][Y],axdot[i][Z]);
- //对标注文本基线的两个端点赋值
- int k=0;
- k=int(count/2)-1;
- copypt(ncspt[0], axdot[k]);
- copypt(ncspt[1], axdot[k+1]);
- //计算巷道断面的四个特征点三维坐标
- ads_point dm[4];
- a=axdot[1][X]-axdot[0][X];
- b=axdot[1][Y]-axdot[0][Y];
- c=sqrt(a*a+b*b);
- d1=temtag.twidth/2;//巷道上宽的一半
- d2=temtag.bwidth/2;//巷道下宽的一半
- ez=temtag.wallhigh;//巷道的净高或拱形巷的墙高
- elx=b*d2/c;
- ely=a*d2/c;
- etx=b*d1/c;
- ety=a*d1/c;
- dm[0][X]=axdot[0][X]+etx;
- dm[0][Y]=axdot[0][Y]-ety;
- dm[0][Z]=axdot[0][Z]+ez;
- dm[1][X]=axdot[0][X]+elx;
- dm[1][Y]=axdot[0][Y]-ely;
- dm[1][Z]=axdot[0][Z];
- dm[2][X]=axdot[0][X]-elx;
- dm[2][Y]=axdot[0][Y]+ely;
- dm[2][Z]=axdot[0][Z];
- dm[3][X]=axdot[0][X]-etx;
- dm[3][Y]=axdot[0][Y]+ety;
- dm[3][Z]=axdot[0][Z]+ez;
- acutPrintf(" 角点坐标n n");
- for(i=0;i<4;i++)
- acutPrintf(" %lf, %lf, %fn",dm[i][X],dm[i][Y],dm[i][Z]);
- //计算拱形巷道断面弧线点
- ads_point ac[11];//拱形线上定义十一个三维中间点
- a=dm[0][X]-dm[3][X];
- b=dm[0][Y]-dm[3][Y];
- float r;
- r=temtag.twidth/2;//给拱形上圆半径赋值
- for(i=0;i<11;i++)
- {
- ac[i][X]=dm[3][X]+(i+1)*a/12;
- ac[i][Y]=dm[3][Y]+(i+1)*b/12;
- ac[i][Z]=dm[3][Z]+sqrt(r*r-(6-(i+1))*(6-(i+1))*r*r/36);
- }
- acutPrintf("拱线点坐标n");
- for(i=0;i<11;i++)
- acutPrintf("%lf, %lf, %fn",ac[i][X],ac[i][Y],ac[i][Z]);
- rc=temtag.tunneltype;
- switch(rc)
- {
- case 701:
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,dm[3],
- RT3DPOINT,ac[0],RT3DPOINT,ac[1],
- RT3DPOINT,ac[2],RT3DPOINT,ac[3],
- RT3DPOINT,ac[4],RT3DPOINT,ac[5],
- RT3DPOINT,ac[6],RT3DPOINT,ac[7],
- RT3DPOINT,ac[8],RT3DPOINT,ac[9],
- RT3DPOINT,ac[10],RT3DPOINT,dm[0],
- RT3DPOINT,dm[1],RT3DPOINT,dm[2],
- RT3DPOINT,dm[3],RTSTR,"",RTNONE);
- break;
- case 702:
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,dm[3],
- RT3DPOINT,dm[0],RT3DPOINT,dm[1],
- RT3DPOINT,dm[2],RT3DPOINT,dm[3],
- RTSTR,"",RTNONE);
- break;
- case 703:
- acedCommand(RTSTR,"circle",RT3DPOINT,axdot[0],RTREAL,temtag.twidth,RTNONE);
- break;
- }
- //获得拉伸断面的实体
- if(ads_entlast(ent1) != RTNORM)
- {
- ads_fail("nFaile creat last entry.");
- return;
- }
- ads_point cp;
- double or1=0.0,or2=0.0,or3,or12;
- double R=0.0,h;
- ads_point mdpt[6]; //声明一个六个点的数组存放圆弧中间插值点的坐标
- for(i=0;i<count;i++)
- {
- rc1=buffer[i].ptype;
- //绘制巷道三维轴线
- switch(rc1)
- {
- case 1:
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,axdot[i],RT3DPOINT,axdot[i+1],RTNONE);
- break;
- case 2:
- calcp(axdot[i],axdot[i+1],axdot[i+2],cp);//计算三点的圆心坐标放入cp点,cp[Z]=axdot[i+1][Z]-axdot[i][Z]
- acutPrintf("下面是cp值n");
- acutPrintf("%lf,%lf,%lfn",cp[X],cp[Y],cp[Z]);
- R=sqrt((cp[X]-axdot[i][X])*(cp[X]-axdot[i][X])+(cp[Y]-axdot[i][Y])*(cp[Y]-axdot[i][Y]));
- or1=ang(cp,axdot[i]); //计算起点与圆心的方位角
- or2=ang(cp,axdot[i+1]); //计算终点与圆心的方位角
- or12=or2-or1; //计算起点与终点的方位角差值
- //判断or12值的取向
- if(or12>pi)
- or12=or12-2*pi;
- if(or12<-pi)
- or12=2*pi+or12;
- h=axdot[i+1][Z]-axdot[i][Z];
- for(j=0;j<5;j++)
- {
- or3=or1+(j+1)*or12/6;
- mdpt[j][X]=cp[X]+R*cos(or3);
- mdpt[j][Y]=cp[Y]+R*sin(or3);
- mdpt[j][Z]=axdot[i][Z]+(j+1)*h/6;
- }
- acutPrintf("下面是mdpt值n");
- for(j=0;j<5;j++)
- acutPrintf("%lf, %lf, %lfn",mdpt[j][X],mdpt[j][Y],mdpt[j][Z]);
- //画出axdot[i]到axdot[i+1]之间的弧线
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,axdot[i],
- RT3DPOINT,mdpt[0],RT3DPOINT,mdpt[1],
- RT3DPOINT,mdpt[2],RT3DPOINT,mdpt[3],
- RT3DPOINT,mdpt[4],RT3DPOINT,axdot[i+1],
- RTNONE);
- break;
- case 3:
- or1=ang(cp,axdot[i]); //计算起点与圆心的方位角,结果放入or1内。
- or2=ang(cp,axdot[i+1]); //计算终点与圆心的方位角,结果放入or2内。
- or12=or2-or1; //计算起点与终点的方位角差值
- //判断or12值的取向
- if(or12>pi)
- or12=or12-2*pi;
- if(or12<-pi)
- or12=2*pi+or12;
- h=axdot[i+1][Z]-axdot[i][Z];
- for(j=0;j<5;j++)
- {
- or3=or1+(j+1)*or12/6;
- mdpt[j][X]=cp[X]+R*cos(or3);
- mdpt[j][Y]=cp[Y]+R*sin(or3);
- mdpt[j][Z]=axdot[i][Z]+(j+1)*h/6;
- }
- //画出axdot[i]到axdot[i+1]之间的弧线
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,axdot[i],
- RT3DPOINT,mdpt[0],RT3DPOINT,mdpt[1],
- RT3DPOINT,mdpt[2],RT3DPOINT,mdpt[3],
- RT3DPOINT,mdpt[4],RT3DPOINT,axdot[i+1],
- RTNONE);
- break;
- //画煤仓标注基线
- case 4:
- acedCommand(RTSTR,"3DPOLY",RT3DPOINT,axdot[i],RT3DPOINT,axdot[i+1],RTNONE);
- break;
- }//switch
- }//for
- acedCommand(RTSTR,"",RTNONE);
- //获得拉伸路径实体
- if(ads_entlast(ent2) != RTNORM)
- {
- ads_fail("nFaile creat last entry.");
- return;
- }
- //把煤仓分成圆柱和圆椎
- if(rc==703)
- {
- //画柱部分
- double hh;
- hh=buffer[count-1].z-buffer[0].z;
- acedCommand(RTSTR,"EXTRUDE",RTENAME,ent1,RTSTR,"",RTREAL,hh,RTANG,0.0,RTNONE);
- //画圆锥部分
- hh=temtag.endhigh-buffer[count-1].z;
- acedCommand(RTSTR,"cone",RT3DPOINT,axdot[count-1],RTREAL,temtag.twidth,
- RTREAL,hh,RTNONE);
- }
- else
- //下面是巷道的拉伸命令
- acedCommand(RTSTR,"EXTRUDE",RTENAME,ent1,RTSTR,"",RTSTR,"P",RTENAME,ent2,RTNONE);
- return;
- }
- void createNewLayer(char* lyrname, Adesk::UInt16 clr, AcDbObjectId ltypeId, Adesk::Boolean current)
- {
- // We need to check if the layer name exists
- // If the layer name exists, apply the color
- // linetype id and whither to make it current
- // or not. In order to be current it cannot be
- // frozen, so we need to check for this also.
- // If the layer name does not exist we just create
- // a new layer with the properties contained in the arguments
- AcDbLayerTable *pLyrTable;
- AcDbLayerTableRecord *pLyrTblRecord;
- AcDbObjectId recId;
- AcCmColor color;
- color.setColorIndex(clr); // set color to parameter clr
- AcDbDatabase *pCurDb = NULL;
- pCurDb = acdbHostApplicationServices()->workingDatabase();
- pCurDb->getLayerTable(pLyrTable, AcDb::kForRead);
- // Check to see if the layer name exists
- if(pLyrTable->has(lyrname))
- {
- pLyrTable->getAt(lyrname, pLyrTblRecord, AcDb::kForWrite, Adesk::kFalse);
- // pLyrTblRecord now points at the layer table record
- // which was opened for write
- pLyrTblRecord->setIsFrozen(Adesk::kFalse);
- pLyrTblRecord->setColor(color);
- pLyrTblRecord->setLinetypeObjectId(ltypeId);
- }
- else
- {
- // Note how we can change the open mode
- // of the layer table from AcDb::kForRead
- // to AcDb::kForWrite
- pLyrTable->upgradeOpen();
- pLyrTblRecord = new AcDbLayerTableRecord;
- pLyrTblRecord->setName(lyrname);
- pLyrTblRecord->setColor(color);
- pLyrTblRecord->setLinetypeObjectId(ltypeId);
- pLyrTable->add(pLyrTblRecord);
- }
- // Get the layer Table ObjectId
- recId = pLyrTblRecord->objectId();
- pLyrTblRecord->close();
- pLyrTable->close();
- // Set the layer current if current
- // is equal to Adesk::kTrue
- // pCurDb is point to the current
- // drawing database
- // The database AcDbDatabase has a number of
- // query and edit functions for the header variables
- if(current)
- {
- pCurDb->setClayer(recId);
- }
- }
- // This is command ' DrawFunction()'
- void DrawFunction()
- {
- const char* title = "打开数据文件"; //设置对话框标题
- const char* default1 = "D:/wzy/"; //设置文件默认路径
- struct resbuf *fname;
- char* pFILENAME; //声明指向文件的指针
- fname = acutNewRb(RTSTR); //为指针设置内存空间
- //获得打开文件的对话框
- if(acedGetFileD(title,default1,"mdb",0,fname)==RTNORM)
- {
- pFILENAME=fname->resval.rstring;
- CString FILENAME=pFILENAME; //把文件路径字符串付值给FILENAME变量
- int Indx=0;
- char attQuery[256];
- sprintf(attQuery,"SELECT * FROM 巷道属性表");//设置SQL查寻语句
- CDaoDatabase db; //声明一个数据库对象
- //按指定路径打开数据库
- db.Open(FILENAME,FALSE,FALSE,_T(""));
- CDaoRecordset pt_rs(&db);//记录集与数据库连接
- CDaoRecordset att_rs(&db);//记录集与数据库连接
- if (att_rs.IsOpen()) att_rs.Close();
- att_rs.Open(dbOpenDynaset,attQuery,0);//动态打开记录集
- //读取属性表数据
- int iRecords =att_rs.GetRecordCount();//统计记录个数
- if (!att_rs.IsBOF()) att_rs.MoveFirst();//把指针移到开始处
- while (!att_rs.IsEOF())
- {
- COleVariant vNameInd =att_rs.GetFieldValue("NameIndex");
- COleVariant vTunName =att_rs.GetFieldValue("Name");
- COleVariant vEndDist = att_rs.GetFieldValue("EndDist");
- COleVariant vEndHigh = att_rs.GetFieldValue("EndHigh");
- COleVariant vTopWidth = att_rs.GetFieldValue("TopWith");
- COleVariant vButWidth = att_rs.GetFieldValue("ButtomWith");
- COleVariant vWallHigh = att_rs.GetFieldValue("WallHigh");
- COleVariant vTunType = att_rs.GetFieldValue("Tunneltype");
- //程序结构变量提取属性数据库字段值
- temtag.nameind=vNameInd.lVal; //巷道名称索引号
- // strcpy(temtag.name,vTunName.bstrVal);//巷道名称字符串
- sprintf(temtag.name,"%s",vTunName.bstrVal);
- temtag.enddist=vEndDist.fltVal; //点至掌头的距离
- temtag.endhigh=vEndHigh.fltVal; //掌头底板高程或煤仓底部高程
- temtag.twidth=vTopWidth.fltVal; //巷道断面上宽或煤仓半径
- temtag.bwidth=vButWidth.fltVal; //巷道断面下宽
- temtag.wallhigh=vWallHigh.fltVal; //拱形指墙高,非拱形指净高
- temtag.tunneltype=vTunType.intVal;//巷道断面类型:701-拱形;703-圆形;702-其它
- char ptQuery[256];
- // CString strSQL;
- // strSQL="SELECT * FROM 巷道控制点数据 WHERE NameIndex=temtag.nameind";
- sprintf(ptQuery,"SELECT * FROM 巷道控制点数据 WHERE NameIndex=%lf",temtag.nameind);
- if (pt_rs.IsOpen()) pt_rs.Close();
- pt_rs.Open(dbOpenDynaset,ptQuery);
- //读取巷道控制点坐标表数据
- int iPtRecords =pt_rs.GetRecordCount();
- if (!pt_rs.IsEOF()) pt_rs.MoveFirst();
- Indx=0;//点记录集索引号清为零
- while (!pt_rs.IsEOF())
- {
- COleVariant vOnlyID = pt_rs.GetFieldValue("OnlyID");//点唯一编号
- COleVariant vX = pt_rs.GetFieldValue("X");//测点X坐标
- COleVariant vY = pt_rs.GetFieldValue("Y");//测点Y坐标
- COleVariant vZ = pt_rs.GetFieldValue("Z");//测点高程
- COleVariant vLD = pt_rs.GetFieldValue("LD");//测点至左邦距离
- COleVariant vRD = pt_rs.GetFieldValue("RD");//测点至右邦距离
- COleVariant vBD = pt_rs.GetFieldValue("BD");//测点至巷道底板值
- COleVariant vPType = pt_rs.GetFieldValue("PType");//1-直线点,2-曲线起点,3-曲线中间点
- //程序结构变量提取巷道坐标数据库字段值
- buffer[Indx].onlyid=vOnlyID.dblVal;
- buffer[Indx].x=vX.dblVal;
- buffer[Indx].y=vY.dblVal;
- buffer[Indx].z=vZ.dblVal;
- buffer[Indx].ld=vLD.fltVal;
- buffer[Indx].rd=vRD.fltVal;
- buffer[Indx].bd=vBD.fltVal;
- buffer[Indx].ptype=vPType.intVal;
- Indx++;
- pt_rs.MoveNext();//指到下一条点集记录
- }//内循环结束(while)
- count=Indx;//记录巷道控制点数
- pt_rs.Close();//关闭点记录集
- // for(i=0;i<Indx;i++)
- // printf("%lf,%lf,%lf,%lfn",buffer[Indx].onlyid,buffer[Indx].x,buffer[Indx].y,buffer[Indx].z);
- char lyrTunnel[50]="巷道";
- char lyrName[50]="名称";
- int col; // Color value
- AcDbObjectId ltypeId; // We need the object id of the linetype
- // for layer creation
- AcDbDatabase *pCurDb = NULL;
- AcDbLinetypeTable *pltTable;
- pCurDb = acdbHostApplicationServices()->workingDatabase();
- pCurDb->getLinetypeTable(pltTable, AcDb::kForRead);
- pltTable->getAt("CONTINUOUS", ltypeId);
- pltTable->close();
- col=6;//巷道层颜色值
- createNewLayer(lyrTunnel, col, ltypeId, Adesk::kTrue);//建立巷道图层
- rbcirc();//计算巷中道轴线坐标绘制巷道
- col=4;//文本层颜色值
- createNewLayer(lyrName, col, ltypeId, Adesk::kTrue);//建立文本图层
- lable(ncspt[0],ncspt[1],temtag.name);//标注刚刚绘出的巷道名称
- att_rs.MoveNext();//指到下一条属性集记录
- }//外循环结束
- att_rs.Close();//关闭属性记录集
- db.Close();
- }//end if
- return;
- }