[301] | 1 | // ----------------------------------------------------------------------- |
---|
| 2 | // mergeIntoList.cc: Add a Detection to a list, merging with existing |
---|
| 3 | // members if necessary. |
---|
| 4 | // ----------------------------------------------------------------------- |
---|
| 5 | // Copyright (C) 2006, Matthew Whiting, ATNF |
---|
| 6 | // |
---|
| 7 | // This program is free software; you can redistribute it and/or modify it |
---|
| 8 | // under the terms of the GNU General Public License as published by the |
---|
| 9 | // Free Software Foundation; either version 2 of the License, or (at your |
---|
| 10 | // option) any later version. |
---|
| 11 | // |
---|
| 12 | // Duchamp is distributed in the hope that it will be useful, but WITHOUT |
---|
| 13 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
| 14 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
| 15 | // for more details. |
---|
| 16 | // |
---|
| 17 | // You should have received a copy of the GNU General Public License |
---|
| 18 | // along with Duchamp; if not, write to the Free Software Foundation, |
---|
| 19 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA |
---|
| 20 | // |
---|
| 21 | // Correspondence concerning Duchamp may be directed to: |
---|
| 22 | // Internet email: Matthew.Whiting [at] atnf.csiro.au |
---|
| 23 | // Postal address: Dr. Matthew Whiting |
---|
| 24 | // Australia Telescope National Facility, CSIRO |
---|
| 25 | // PO Box 76 |
---|
| 26 | // Epping NSW 1710 |
---|
| 27 | // AUSTRALIA |
---|
| 28 | // ----------------------------------------------------------------------- |
---|
[3] | 29 | #include <vector> |
---|
[393] | 30 | #include <duchamp/Cubes/cubes.hh> |
---|
| 31 | #include <duchamp/Utils/utils.hh> |
---|
[3] | 32 | |
---|
[378] | 33 | namespace duchamp |
---|
[3] | 34 | { |
---|
| 35 | |
---|
[770] | 36 | void mergeIntoList(Detection &object, std::vector <Detection> &objList, Param &par) |
---|
[378] | 37 | { |
---|
[528] | 38 | /// @details |
---|
| 39 | /// A function to add a detection to a list of detections, checking |
---|
| 40 | /// first to see if it can be combined with existing members of the |
---|
| 41 | /// list. |
---|
| 42 | /// |
---|
[770] | 43 | /// The areClose testing and combining is done with the |
---|
| 44 | /// parameters as given by the Param set. |
---|
[528] | 45 | /// |
---|
| 46 | /// \param object The Detection to be merged into the list. |
---|
| 47 | /// \param objList The vector list of Detections. |
---|
| 48 | /// \param par The Param set, used for testing if merging needs to be done. |
---|
[136] | 49 | |
---|
[378] | 50 | bool haveMerged = false; |
---|
| 51 | |
---|
| 52 | std::vector<Detection>::iterator iter; |
---|
[770] | 53 | |
---|
| 54 | for(iter=objList.begin(); (!haveMerged && iter<objList.end()); iter++) { |
---|
| 55 | if(iter->canMerge(object,par)){ |
---|
| 56 | iter->addDetection(object); |
---|
[378] | 57 | haveMerged = true; |
---|
[770] | 58 | } |
---|
[258] | 59 | } |
---|
| 60 | |
---|
[378] | 61 | if(!haveMerged) objList.push_back(object); |
---|
[3] | 62 | |
---|
[378] | 63 | } |
---|
| 64 | |
---|
[3] | 65 | } |
---|