contrib/mul/mfpf/mfpf_sort_matches.cxx
Go to the documentation of this file.
00001 #include "mfpf_sort_matches.h"
00002 //:
00003 // \file
00004 // \brief Sorts matches so first has smallest fit
00005 // \author Tim Cootes
00006 
00007 #include <mbl/mbl_index_sort.h>
00008 
00009 //: Sorts matches so first has smallest fit
00010 //  Sorts so that pose[0] is best fit (ie smallest fit value)
00011 void mfpf_sort_matches(vcl_vector<mfpf_pose>& poses,
00012                        vcl_vector<double>& fits)
00013 {
00014   vcl_vector<double> fits0=fits;
00015   vcl_vector<mfpf_pose> poses0=poses;
00016   vcl_vector<int> index;
00017   mbl_index_sort(fits,index);
00018   for (unsigned i=0;i<index.size();++i)
00019   {
00020     poses[i]=poses0[index[i]];
00021     fits[i] =fits0[index[i]];
00022   }
00023 }
00024 
00025 //: Sorts so that pose_set.pose[0] is best fit (ie smallest fit value)
00026 void mfpf_sort_matches(mfpf_pose_set& pose_set)
00027 {
00028   mfpf_sort_matches(pose_set.poses,pose_set.fits);
00029 }