64,683
社区成员
发帖
与我相关
我的任务
分享
0.0000000000 0.0000000000 -1.0000000000
1000.0000000000 0.0000000000 0.0000000000
0.0000000000 0.0000000000 0.0000000000
1000.0000000000 600.0000000000 0.0000000000
0.0000000000 0.0000000000 -1.0000000000
0.0000000000 0.0000000000 0.0000000000
0.0000000000 600.0000000000 0.0000000000
1000.0000000000 600.0000000000 0.0000000000
-1.0000000000 0.0000000000 0.0000000000
0.0000000000 600.0000000000 600.0000000000
0.0000000000 600.0000000000 0.0000000000
0.0000000000 0.0000000000 600.0000000000
-1.0000000000 0.0000000000 0.0000000000
0.0000000000 600.0000000000 0.0000000000
0.0000000000 0.0000000000 0.0000000000
0.0000000000 0.0000000000 600.0000000000
1.0000000000 0.0000000000 0.0000000000
1000.0000000000 0.0000000000 600.0000000000
1000.0000000000 0.0000000000 0.0000000000
1000.0000000000 600.0000000000 600.0000000000
1.0000000000 0.0000000000 0.0000000000
1000.0000000000 0.0000000000 0.0000000000
1000.0000000000 600.0000000000 0.0000000000
1000.0000000000 600.0000000000 600.0000000000
0.1961161400 0.0000000000 0.9805806800
500.0000000000 0.0000000000 700.0000000000
1000.0000000000 0.0000000000 600.0000000000
500.0000000000 600.0000000000 700.0000000000
0.1961161400 0.0000000000 0.9805806800
1000.0000000000 0.0000000000 600.0000000000
1000.0000000000 600.0000000000 600.0000000000
500.0000000000 600.0000000000 700.0000000000
-0.1961161400 0.0000000000 0.9805806800
0.0000000000 0.0000000000 600.0000000000
500.0000000000 0.0000000000 700.0000000000
0.0000000000 600.0000000000 600.0000000000
-0.1961161400 0.0000000000 0.9805806800
500.0000000000 0.0000000000 700.0000000000
500.0000000000 600.0000000000 700.0000000000
0.0000000000 600.0000000000 600.0000000000
0.0000000000 -1.0000000000 0.0000000000
0.0000000000 0.0000000000 600.0000000000
0.0000000000 0.0000000000 0.0000000000
500.0000000000 0.0000000000 700.0000000000
0.0000000000 -1.0000000000 0.0000000000
0.0000000000 0.0000000000 0.0000000000
1000.0000000000 0.0000000000 0.0000000000
500.0000000000 0.0000000000 700.0000000000
0.0000000000 -1.0000000000 0.0000000000
1000.0000000000 0.0000000000 0.0000000000
1000.0000000000 0.0000000000 600.0000000000
500.0000000000 0.0000000000 700.0000000000
0.0000000000 1.0000000000 0.0000000000
0.0000000000 600.0000000000 600.0000000000
500.0000000000 600.0000000000 700.0000000000
0.0000000000 600.0000000000 0.0000000000
0.0000000000 1.0000000000 0.0000000000
1000.0000000000 600.0000000000 600.0000000000
1000.0000000000 600.0000000000 0.0000000000
500.0000000000 600.0000000000 700.0000000000
0.0000000000 1.0000000000 0.0000000000
1000.0000000000 600.0000000000 0.0000000000
0.0000000000 600.0000000000 0.0000000000
500.0000000000 600.0000000000 700.0000000000
请按任意键继续. . .
#include<iostream>
#include <iterator>
#include <fstream>
#include<string>
using namespace std;
struct FaceMsg
{
FaceMsg():m_flag(false){}
double m_Normal[3];
double m_Vertex0[3];
double m_Vertex1[3];
double m_Vertex2[3];
bool m_flag;
};
FaceMsg Data[20];
int statistics( const char *pFileName )
{
int count=0;
ifstream infile( pFileName );
if( infile.fail() ){return false;}
istream_iterator<string> bg(infile);
istream_iterator<string> ed;
for( bg; bg!=ed; ++bg )
{
if( *bg=="normal" )
{
bg++; //跳过normal
//存放法线
for(int j=0; j<3; j++, bg++)
Data[count].m_Normal[j]=atof(bg->c_str());
//跳过loop,vertex;
bg++; bg++; bg++;
for(int j=0; j<3; j++, bg++)
Data[count].m_Vertex0[j]=atof(bg->c_str());
bg++;
for(int j=0; j<3; j++, bg++)
Data[count].m_Vertex1[j]=atof(bg->c_str());
bg++;
for(int j=0; j<3; j++, bg++)
Data[count].m_Vertex2[j]=atof(bg->c_str());
count++; //面数加加
}
}
infile.close();
return count;
}
int main()
{
int count=statistics("input.txt");
for (int i=0; i<count; i++)
{
for(int j=0; j<3; j++)
printf("%14.10f\t", Data[i].m_Normal[j]);
printf("\n");
for(int j=0; j<3; j++)
printf("%14.10f\t", Data[i].m_Vertex0[j]);
printf("\n");
for(int j=0; j<3; j++)
printf("%14.10f\t", Data[i].m_Vertex1[j]);
printf("\n");
for(int j=0; j<3; j++)
printf("%14.10f\t", Data[i].m_Vertex2[j]);
printf("\n");
}
}