Improved float/double when reading ascii formats (read in double and then convert to the needed type)

This commit is contained in:
Paolo Cignoni 2014-07-01 09:46:46 +00:00
parent d127123513
commit aa63261fae
2 changed files with 4 additions and 4 deletions

View File

@ -76,7 +76,7 @@ static void readline(FILE *fp, char *line, int max=100){
static bool ReadHeader(FILE *fp,unsigned int &num_cams, unsigned int &num_points){ static bool ReadHeader(FILE *fp,unsigned int &num_cams, unsigned int &num_points){
char line[100]; char line[100];
readline(fp, line); readline(fp, line);
if( (line[0]=='\0') ) return false; if( line[0]=='\0' ) return false;
line[18]='\0'; line[18]='\0';
if(0!=strcmp("# Bundle file v0.3", line)) return false; if(0!=strcmp("# Bundle file v0.3", line)) return false;
readline(fp, line); readline(fp, line);
@ -168,7 +168,7 @@ static int Open( OpenMeshType &m, std::vector<Shot<ScalarType> > & shots,
fscanf(fp,"%d ",&n_corr); fscanf(fp,"%d ",&n_corr);
for(uint j = 0; j < n_corr; ++j){ for(uint j = 0; j < n_corr; ++j){
fscanf(fp,"%d %d %f %f ",&i_cam,&key_sift,&x,&y); fscanf(fp,"%d %d %lf %lf ",&i_cam,&key_sift,&x,&y);
Correspondence corr(i_cam,key_sift,x,y); Correspondence corr(i_cam,key_sift,x,y);
ch[i].push_back(corr); ch[i].push_back(corr);
} }

View File

@ -272,9 +272,9 @@ public:
// read the stream // read the stream
if(hascolor) if(hascolor)
fscanf(fp,"%f %f %f %f %f %f %f", &xx, &yy, &zz, &rf, &rr, &gg, &bb); fscanf(fp,"%lf %lf %lf %f %f %f %f", &xx, &yy, &zz, &rf, &rr, &gg, &bb);
else else
fscanf(fp,"%f %f %f %f", &xx, &yy, &zz, &rf); fscanf(fp,"%lf %lf %lf %f", &xx, &yy, &zz, &rf);
// add the point // add the point
(*vi).P()[0]=xx; (*vi).P()[0]=xx;