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

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

Changed source tree structure: added a src/ directory that contains all the
code. Makefile.in and configure.ac changed to match.

File size: 1.4 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      *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.