4pcs: Small optimization (preallocation of vector instead of pushback)

This commit is contained in:
Paolo Cignoni 2014-04-18 13:39:52 +00:00
parent b01b731b75
commit 30a7ecf743
1 changed files with 6 additions and 4 deletions

View File

@ -323,10 +323,12 @@ return true;
template <class MeshType> template <class MeshType>
bool FourPCS<MeshType>::IsTransfCongruent(FourPoints fp, vcg::Matrix44<ScalarType> & mat, float & trerr) bool FourPCS<MeshType>::IsTransfCongruent(FourPoints fp, vcg::Matrix44<ScalarType> & mat, float & trerr)
{ {
std::vector<vcg::Point3<ScalarType> > fix; std::vector<vcg::Point3<ScalarType> > fix(4);
std::vector<vcg::Point3<ScalarType> > mov; std::vector<vcg::Point3<ScalarType> > mov(4);
for(int i = 0 ; i < 4; ++i) mov.push_back(B[i]); for(int i = 0 ; i < 4; ++i) {
for(int i = 0 ; i < 4; ++i) fix.push_back(fp[i]); mov[i]=B[i];
fix[i]=fp[i];
}
if(fabs( Distance(fix[0],fix[1]) - Distance(mov[0],mov[1]) ) > par.delta) return false; if(fabs( Distance(fix[0],fix[1]) - Distance(mov[0],mov[1]) ) > par.delta) return false;
if(fabs( Distance(fix[0],fix[2]) - Distance(mov[0],mov[2]) ) > par.delta) return false; if(fabs( Distance(fix[0],fix[2]) - Distance(mov[0],mov[2]) ) > par.delta) return false;