remove fscanf from outline2_packer.h

This commit is contained in:
alemuntoni 2021-10-20 10:29:25 +02:00
parent 4d6c87c579
commit 412c904a17
1 changed files with 20 additions and 21 deletions

View File

@ -1,4 +1,4 @@
/**************************************************************************** /****************************************************************************
* VCGLib o o * * VCGLib o o *
* Visual and Computer Graphics Library o o * * Visual and Computer Graphics Library o o *
* _ O _ * * _ O _ *
@ -24,6 +24,7 @@
#define __VCG_OUTLINE2_PACKER_H__ #define __VCG_OUTLINE2_PACKER_H__
#include <limits> #include <limits>
#include <fstream>
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <vcg/space/box2.h> #include <vcg/space/box2.h>
@ -212,26 +213,24 @@ static bool WritePolyVec(const std::vector< std::vector<Point2x> > &polyVec, con
static bool ReadPolyVec(std::vector< std::vector<Point2x> > &polyVec, const char *filename) static bool ReadPolyVec(std::vector< std::vector<Point2x> > &polyVec, const char *filename)
{ {
FILE *fp=fopen(filename,"r"); std::ifstream ifs(filename, std::ifstream::in);
if(!fp) return false; if (!ifs.is_open()) return false;
int sz; int sz;
fscanf(fp,"%i\n",&sz); ifs >> sz;
polyVec.clear(); polyVec.resize(sz);
polyVec.resize(sz); for (std::size_t i = 0; i < sz; ++i){
for(size_t i=0;i<polyVec.size();++i) int isz;
{ ifs >> isz;
fscanf(fp,"%i\n",&sz); polyVec[i].resize(isz);
polyVec[i].resize(sz); for (std::size_t j = 0; j < isz; ++j){
for(size_t j=0;j<polyVec[i].size();++j) float x, y;
{ ifs >> x >> y;
float x,y; polyVec[i][j].X() = x;
fscanf(fp,"%f %f",&x,&y); polyVec[i][j].Y() = y;
polyVec[i][j].X()=x; }
polyVec[i][j].Y()=y; }
} ifs.close();
} return true;
fclose(fp);
return true;
} }