source: trunk/Detection/mergeIntoList.cc @ 3

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

This is the first full import of all working code to
the Duchamp repository.
Made three directories at top level:

branches/ tags/ trunk/

and trunk/ has the full set of code:
ATrous/ Cubes/ Detection/ InputComplete? InputExample? README Utils/ docs/ mainDuchamp.cc param.cc param.hh

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