#include #include #include using std::vector; class Pair { public: Pair(){}; virtual ~Pair(){}; friend bool operator< (const Pair& lhs, const Pair& rhs){ return (lhs.primary < rhs.primary); }; void define(float p, float m){primary=p; matching=m;}; float get1(){return primary;}; float get2(){return matching;}; private: float primary; float matching; }; void Detection::SortByZ() { /** * Detection::SortByZ(): * A Function that takes a Detection and * sorts the pixels by z-pixel * Upon return, the inputList is sorted. * We use stable_sort, so that the order of objects with the same * z-value is preserved. */ long size = this->pix.size(); Pair *info = new Pair[size]; for(int i=0;ipix[i].getZ(),float(i)); std::stable_sort(info,info+size); vector sorted(size); for(int i=0;ipix[int(info[i].get2())] ; delete [] info; for(int i=0;ipix.erase(this->pix.begin()+i); this->pix.insert(this->pix.begin()+i, sorted[i]); } sorted.clear(); } void SortByZ(vector &inputList) { /** * SortByZ(vector &): * A Function that takes a list of Detections and * sorts them in order of increasing z-pixel value. * Upon return, the inputList is sorted. */ long size = inputList.size(); Pair *info = new Pair[size]; for(int i=0;i sorted; for(int i=0;i &inputList) { /** * SortByVel(vector &): * A Function that takes a list of Detections and * sorts them in order of increasing velocity. * Every member of the vector needs to have WCS defined, (and if so, * then vel is assumed to be defined for all), otherwise no sorting * is done. * Upon return (if all WCS are good), the inputList is sorted. */ bool isGood = true; for(int i=0;i sorted; for(int i=0;i