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,25 +213,23 @@ 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(size_t i=0;i<polyVec.size();++i) for (std::size_t i = 0; i < sz; ++i){
{ int isz;
fscanf(fp,"%i\n",&sz); ifs >> isz;
polyVec[i].resize(sz); polyVec[i].resize(isz);
for(size_t j=0;j<polyVec[i].size();++j) for (std::size_t j = 0; j < isz; ++j){
{ float x, y;
float x,y; ifs >> x >> y;
fscanf(fp,"%f %f",&x,&y); polyVec[i][j].X() = x;
polyVec[i][j].X()=x; polyVec[i][j].Y() = y;
polyVec[i][j].Y()=y;
} }
} }
fclose(fp); ifs.close();
return true; return true;
} }