source: trunk/src/Detection/mergeIntoList.cc @ 136

Last change on this file since 136 was 136, checked in by Matthew Whiting, 18 years ago

Range of alterations... :
Cubes/cubes.cc -- added new front-end to the getopt function, that reads the

command-line options. Makes calling it easier from other
programs.
Slight alteration to Image::removeMW()
Moved Cube::setupColumns() to here, with different flow.

Cubes/cubes.hh -- Prototypes for above.
mainDuchamp.cc -- Removed call to getopt -- now a Cube:: function
Detection/spectrumDetect.cc -- Trying a new way of doing it -- just Detection,

rather than a vector.

Detection/columns.cc -- Changed this around a bit. Made two new functions that

return a ColSet? for either the full case or the logging
case. Cube::setupColumns() now calls these

Detection/mergeIntoList.cc -- minor edit
Detection/columns.hh -- change declaration orders and new prototypes.

File size: 1.3 KB
Line 
1#include <vector>
2#include <Cubes/cubes.hh>
3#include <Utils/utils.hh>
4
5void mergeIntoList(Detection &object, vector <Detection> &objList, Param &par)
6{
7  /**
8   *  mergeIntoList(Detection &, vector<Detection> &, Param &)
9   *
10   *   A function to add a detection to a list of detections, checking
11   *   first to see if it can be merged with existing members of the list.
12   *   The merging is only done if the object is adjacent to one of the existing
13   *   members -- this is considered in all three directions.
14   *        To this end, the adjacent flag in par is set true, and the velocity
15   *        threshold is set to 1. These parameters are changed back before returning.
16   */
17
18  bool haveMerged = false;
19  bool flagAdjacent = par.getFlagAdjacent();
20  par.setFlagAdjacent(true);
21  float threshold = par.getThreshV();
22  par.setThreshV(1.);
23
24  long ctr = 0;
25  if(objList.size()>0){
26    do {
27      Detection *obj2 = new Detection;
28      *obj2 = objList[ctr];
29      if(areClose(object, *obj2, par)){
30        obj2->addAnObject(object);
31        objList.erase( objList.begin() + ctr );
32        objList.push_back( *obj2 );
33        haveMerged = true;
34      }
35      else ctr++;
36      delete obj2;
37     
38    } while( !(haveMerged) && (ctr<objList.size()) );
39  }
40
41  if(!haveMerged) objList.push_back(object);
42
43  par.setFlagAdjacent(flagAdjacent);
44  par.setThreshV(threshold);
45
46}
Note: See TracBrowser for help on using the repository browser.