00006 {
00007 ifstream file(filename);
00008
00009 string line;
00010 string pX,pY,pZ;
00011
00012
Point3D *p;
00013
float px=0.0 , py=0.0 , pz=0.0;
00014
int goodPosition = 0;
00015
int describePoly = 0;
00016
int endIndexedFace = 0;
00017
00018
int refp1,refp2,refp3;
00019
00020
00021
while((getline(file, line)&&(endIndexedFace==0))) {
00022
delSpace(line);
00023
00024
00025
if(goodPosition==0){
00026
while(line.find(
"point",0)==string::npos)
00027 getline(file,line);
delSpace(line);
00028 goodPosition=1;
00029 }
00030
else
00031 {
00032
if(line.find(
"coordIndex",0)!=string::npos)
00033 {
00034 describePoly=1;
00035 getline(file,line);
00036
delSpace(line);
00037 }
00038
00039
if(describePoly==0)
00040 {
00041
if(line[0]!=
'}')
00042 {
00043
unsigned int i=0;
00044
00045
00046
while((line[i]!=
' ')&&(i<line.size()))i++;
00047
00048 px=
stof(line.substr(0,i));
00049
00050
unsigned int j=i+1;
00051
00052
while((line[j]!=
' ')&&(j<line.size()))j++;
00053 py=
stof(line.substr(i+1,j-i-1));
00054
00055
unsigned int k=j+1;
00056
while((line[k]!=
',')&&(line[k]!=
']')&&(k<line.size()))k++;
00057 pz=
stof(line.substr(j+1,k-j-1));
00058
00059
00060 p =
new Point3D(px,py,pz);
00061
00062
00063
00064
pointsList.push_back(p);
00065
00066 }
00067
00068 }
00069
else
00070 {
00071
if(line[0]!=
'}')
00072 {
00073
00074
unsigned int i=0;
00075
00076
while((line[i]!=
',')&&(i<line.size()))i++;
00077
00078 refp1=
stoi(line.substr(0,i));
00079
referencesList.push_back(refp1);
00080
00081
unsigned int j=i+1;
00082
00083
00084
while((line[j]!=
',')&&(j<line.size()))j++;
00085
00086 refp2=
stoi(line.substr(i+2,j-i-1));
00087
00088
referencesList.push_back(refp2);
00089
00090
00091
unsigned int k=j+1;
00092
while((line[k]!=
',')&&(line[k]!=
']')&&(k<line.size()))k++;
00093
00094
00095 refp3=
stoi(line.substr(j+2,k-j-2));
00096
referencesList.push_back(refp3);
00097
if(line.find(
"]",0)!=string::npos)
00098 endIndexedFace=1;
00099 }
00100 }
00101 }
00102
00103
00104 }
00105
00106
nbPoints =
pointsList.size();
00107
nbPolys =
referencesList.size()/3;
00108 file.close();
00109
00110 }