double x=0,y=0,z=0,pI=0,pJ=0,R=0; int indexx=0,indexy=0,indexz=0,indexC[5]={0,0,0,0,0}; int lightx=0,lighty=0,lightz=0,lightC[5]={0,0,0,0,0}; CString m_data; m_data=(CString)Path+"/"+m_filetitle+"_data.dat"; ifstream FileIn(m_str, ios::in); // ofstream FileOut(m_data, ios::out);
while(!FileIn.eof()) { FileIn.getline(line,256,'\n'); // 读出文件的一行数据 for(int i=0;i<=strlen(line);i++)// 如果此行中有'X','Y','Z',则分别标记各自的light,并返回它们的位置index { if(line=='X') { indexx=i; lightx=1; } if(line=='Y') { indexy=i; if(indexy!=0) if((line[indexy-1]=='P')||(line[indexy-1]=='T')) lighty=0; else lighty=1; else lighty=1; } if(line=='Z') { indexz=i; lightz=1; } if((line=='G')&&((line[i+1]=='2')||(line[i+2]=='2'))) { indexC[0]=i; lightC[0]=1; } if((line=='G')&&((line[i+1]=='3')||(line[i+2]=='3'))) { indexC[1]=i; lightC[1]=1; } if(line=='I') { indexC[2]=i; lightC[2]=1; } if(line=='J') { indexC[3]=i; lightC[3]=1; } if(line=='R') { indexC[4]=i; lightC[4]=1; } } // 如果此行中有'X','Y','Z',则分别标记各自的light,并返回它们的位置index if(lightx==1) // 如果标记'X','Y','Z'的灯亮,则分别取出各自的数值 { for(int countx=indexx+1;countx<indexx+11;countx++) { if(('0'<=line[countx]<='9')||(line[countx]=='.')||(line[countx]=='-')) tempchar[countx-indexx-1]=line[countx]; } x=atof(tempchar); countx=0; } if(lighty==1) { for(int county=indexy+1;county<indexy+11;county++) { if(('0'<=line[county]<='9')||(line[county]=='.')||(line[county]=='-')) tempchar[county-indexy-1]=line[county]; } y=atof(tempchar); county=0; } if(lightz==1) { for(int countz=indexz+1;countz<indexz+11;countz++) { if(('0'<=line[countz]<='9')||(line[countz]=='.')||(line[countz]=='-')) tempchar[countz-indexz-1]=line[countz]; } z=atof(tempchar); countz=0; } // 如果标记'X','Y','Z'的灯亮,则分别取出各自的数值 if(lightC[2]==1) { for(int countI=indexC[2]+1;countI<indexC[2]+11;countI++) { if(('0'<=line[countI]<='9')||(line[countI]=='.')||(line[countI]=='-')) tempchar[countI-indexC[2]-1]=line[countI]; } pI=atof(tempchar); countI=0; } if(lightC[3]==1) { for(int countJ=indexC[3]+1;countJ<indexC[3]+11;countJ++) { if(('0'<=line[countJ]<='9')||(line[countJ]=='.')||(line[countJ]=='-')) tempchar[countJ-indexC[3]-1]=line[countJ]; } pJ=atof(tempchar); countJ=0; } if(lightC[4]==1) { for(int countR=indexC[4]+1;countR<indexC[4]+11;countR++) { if(('0'<=line[countR]<='9')||(line[countR]=='.')) tempchar[countR-indexC[4]-1]=line[countR]; } R=atof(tempchar); countR=0; } if((lightx==1)||(lighty==1)||(lightz==1)) { Cpt(pts,pte); Spt(pte,x,y,z); lightx=0; lighty=0; lightz=0; indexx=0; indexy=0; indexz=0; /* if((lightC[0]==1)||(lightC[1]==1)) { for(int i=0;i<5;i++) { lightC=0; indexC=0; } }*/ if((pte[0]!=pts[0])||(pte[1]!=pts[1])||(pte[2]!=pts[2])) { if((lightC[0]!=1)&&(lightC[1]!=1)) { CMjtClass *ln=new CMjtClass;// 产生CMjtClass类的对象 AcDbLine *pLine; // 产生直线类的对象 AcGePoint3d pt1,pt2;// 产生AcGePoint3d格式的点 Cpt(pt1,pts); // 赋值产生的点 Cpt(pt2,pte); pLine = ln->createLine(pt1,pt2); // pLine->setColorIndex(index_color<255?index_color:index_color%255); pLine->close(); delete ln; } else { CMjtClass *arc=new CMjtClass;// 产生CMjtClass类的对象 AcDbArc *pArc; ads_point pta1,pta2,pta0; Cpt(pta1,pts); Cpt(pta2,pte); Spt(pta0,pta1[0]+pI,pta1[1]+pJ,pta1[2]); double angles,anglee,rad; angles=acutAngle(pta0,pta1); anglee=acutAngle(pta0,pta2); rad=acutDistance(pta1,pta0); AcGePoint3d ptc(pta0[0],pta0[1],pta0[2]); if(lightC[1]==1) { pArc = arc->createCircle(ptc,rad,angles,anglee); } else { pArc = arc->createCircle(ptc,rad,anglee,angles); } pArc->close(); delete arc; for(int i=0;i<5;i++) { lightC=0; indexC=0; } } } else acutPrintf("\n 连续相同的点被忽略!"); index_color++; // acedCommand(RTSTR,"zoom",RTSTR,"extent",0); /* if(((CButton *)GetDlgItem(IDC_CHECK1))->GetCheck()) FileOut<<pts[0]<<" "<<pts[1]<<" "<<pts[2]<<endl;*/ } } acedCommand(RTSTR,"zoom",RTSTR,"extent",0); FileIn.close(); |