From 30a7ecf7430ac92fe0b61802669ba4cbcf010887 Mon Sep 17 00:00:00 2001 From: cignoni Date: Fri, 18 Apr 2014 13:39:52 +0000 Subject: [PATCH] 4pcs: Small optimization (preallocation of vector instead of pushback) --- vcg/complex/algorithms/autoalign_4pcs.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/vcg/complex/algorithms/autoalign_4pcs.h b/vcg/complex/algorithms/autoalign_4pcs.h index cf7370a5..617a1f58 100644 --- a/vcg/complex/algorithms/autoalign_4pcs.h +++ b/vcg/complex/algorithms/autoalign_4pcs.h @@ -323,10 +323,12 @@ return true; template bool FourPCS::IsTransfCongruent(FourPoints fp, vcg::Matrix44 & mat, float & trerr) { - std::vector > fix; - std::vector > mov; - for(int i = 0 ; i < 4; ++i) mov.push_back(B[i]); - for(int i = 0 ; i < 4; ++i) fix.push_back(fp[i]); + std::vector > fix(4); + std::vector > mov(4); + for(int i = 0 ; i < 4; ++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[2]) - Distance(mov[0],mov[2]) ) > par.delta) return false;