我有如下格式的文件,每一行为一个三维点的x,y,z坐标值(点的数目不定)。…………………………215.6822   225.6726   -70.67117
211.7681   258.8258   -15.84312
241.7205   244.6382    27.85714
253.7391  146.1325    36.15568
199.9012   125.72        57.52445
71.90759   201.9745     61.01708
304.2344    161.6351      8.54886
-0.8825507     229.0641    1.749303
30.37378    203.0423     -59.81339………………………………我按照下面的代码来读入点数据,当文件中的点数较少时,程序运行正常。但是当点数较多时(上万),程序就死了。怎么才能改进算法啊,请大家帮帮我啊。void CNotepadView::OnFileOpen() 
{
 // TODO: Add your command handler code here
 TCHAR szFilters[]=_T("Text files(*.asc)|*.asc|All files(*.*)|*.*||");
 CFileDialog dlg(TRUE,_T("asc"),_T("*.asc"),OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,szFilters);
    if(dlg.DoModal()==IDOK)
  filename=dlg.GetPathName(); FILE* file;
 if((file = fopen(filename, "r")) == NULL)
  AfxMessageBox("Can not open file!") ; CPoint3D point;
 while(!feof(file))
 {
  
  fscanf(file,"%lf %lf %lf",&(point.x),&(point.y),&(point.z)); 
  points.Add(point);
 }  fclose(file); 
}

解决方案 »

  1.   

    格式一至,用一个结构存盘读写;如struct tmp{float f1,f2,f3;}tmp;
      

  2.   

    其中,CPoint是自己定义的点类,points是成员变量,表示点集 CArray<CPoint3D,CPoint3D &>points;
    麻烦大家帮我看看怎么改进啊?
      

  3.   

    3jaja(3++输入法),我必须要用自己定义的类CPoint3D来管理这些数据,因为后面还有一些计算问题啊。