source: branches/fitshead-branch/Detection/mergeIntoList.cc @ 1441

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

Coding fixes, improving the readability of the code, particularly regarding
the declaration of temporary variables. Files affected:
Detection/areClose.cc
Detection/detection.cc
Detection/thresholding_functions.cc
Detection/growObject.cc
Detection/mergeIntoList.cc
Detection/lutz_detect.cc

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  long ctr = 0;
24  if(objList.size()>0){
25    do {
26      Detection *obj2 = new Detection;
27      *obj2 = objList.at(ctr);
28      if(areClose(object, *obj2, par)){
29        obj2->addAnObject(object);
30        objList.erase( objList.begin() + ctr );
31        objList.push_back( *obj2 );
32        haveMerged = true;
33      }
34      else ctr++;
35      delete obj2;
36     
37    } while( !(haveMerged) && (ctr<objList.size()) );
38  }
39
40  if(!haveMerged) objList.push_back(object);
41
42  par.setFlagAdjacent(flagAdjacent);
43  par.setThreshV(threshold);
44
45}
Note: See TracBrowser for help on using the repository browser.