remove sprintf from hole.h, plymc.h and volume.h

This commit is contained in:
alemuntoni 2021-10-19 18:25:28 +02:00
parent 78cad04cb9
commit 10e8502717
3 changed files with 9 additions and 9 deletions

View File

@ -597,7 +597,6 @@ int MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBack
//qDebug("Simplifying at absoluteError=%f",absoluteError); //qDebug("Simplifying at absoluteError=%f",absoluteError);
float TargetError = absoluteError; float TargetError = absoluteError;
char buf[1024];
DeciSession.template Init< MyColl > (); DeciSession.template Init< MyColl > ();
pp.areaThr=TargetError*TargetError; pp.areaThr=TargetError*TargetError;
@ -605,8 +604,9 @@ int MCSimplify( MeshType &m, float absoluteError, bool preserveBB, vcg::CallBack
if(TargetError < std::numeric_limits<float>::max() ) DeciSession.SetTargetMetric(TargetError); if(TargetError < std::numeric_limits<float>::max() ) DeciSession.SetTargetMetric(TargetError);
while(DeciSession.DoOptimization() && DeciSession.currMetric < TargetError) while(DeciSession.DoOptimization() && DeciSession.currMetric < TargetError)
{ {
sprintf(buf,"Simplyfing %7i err %9g \r",m.fn,DeciSession.currMetric); std::string buf = "Simplyfing " + std::to_string(m.fn) + " err " + std::to_string(DeciSession.currMetric) + " \r";
if (cb) cb(int(100.0f*DeciSession.currMetric/TargetError),buf); if (cb)
cb(int(100.0f*DeciSession.currMetric/TargetError),buf.c_str());
} }
return 1; //success return 1; //success

View File

@ -42,7 +42,7 @@ const char *SFormat( const char * f, ... )
static char buf[4096]; static char buf[4096];
va_list marker; va_list marker;
va_start( marker, f ); va_start( marker, f );
vsprintf(buf,f,marker); vsnprintf(buf,4096,f,marker);
va_end( marker ); va_end( marker );
return buf; return buf;
} }
@ -301,9 +301,9 @@ public:
void GetSubVolumeTag(std::string &subtag) void GetSubVolumeTag(std::string &subtag)
{ {
char buf[32]; char buf[32];
if (div[0]<= 10 && div[1]<= 10 && div[2]<= 10 ) sprintf(buf,"_%01d%01d%01d",pos[0],pos[1],pos[2]); if (div[0]<= 10 && div[1]<= 10 && div[2]<= 10 ) snprintf(buf,32,"_%01d%01d%01d",pos[0],pos[1],pos[2]);
else if(div[0]<= 100 && div[1]<= 100 && div[2]<= 100 ) sprintf(buf,"_%02d%02d%02d",pos[0],pos[1],pos[2]); else if(div[0]<= 100 && div[1]<= 100 && div[2]<= 100 ) snprintf(buf,32,"_%02d%02d%02d",pos[0],pos[1],pos[2]);
else sprintf(buf,"_%03d%03d%03d",pos[0],pos[1],pos[2]); else snprintf(buf,32,"_%03d%03d%03d",pos[0],pos[1],pos[2]);
subtag=buf; subtag=buf;
} }

View File

@ -291,8 +291,8 @@ public:
typename MESH::ScalarType aspectRatio; typename MESH::ScalarType aspectRatio;
const char * Dump() { const char * Dump() {
static char buf[200]; static char buf[200];
if(this->IsConcave()) sprintf(buf,"Dihedral -(deg) %6.2f Quality %6.2f\n",math::ToDeg(dihedralRad),aspectRatio); if(this->IsConcave()) snprintf(buf,200,"Dihedral -(deg) %6.2f Quality %6.2f\n",math::ToDeg(dihedralRad),aspectRatio);
else sprintf(buf,"Dihedral (deg) %6.2f Quality %6.2f\n",math::ToDeg(dihedralRad),aspectRatio); else snprintf(buf,200,"Dihedral (deg) %6.2f Quality %6.2f\n",math::ToDeg(dihedralRad),aspectRatio);
return buf; return buf;
} }