source: tags/release-1.0.5/src/Detection/mergeIntoList.cc @ 1455

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

A few new things:

  • Made a mycpgplot.hh file, to keep PGPlot-related constants (enum types)

in a standard namespace (so one can do cpgsci(RED) rather than cpgsci(2)...).
Incorporated this into all code that uses pgplot.

  • Improved the outputting of the number of detected objects in the search

functions. Now shows how many have been detected, before they are merged
into the list.

  • Fixed a bug in columns.cc that was incorrectly updating the precision for

negative velocities.

  • Additional text in the Guide, and general clean up of code.
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.