source: branches/pixel-map-branch/src/Utils/Section.hh

Last change on this file was 254, checked in by Matthew Whiting, 17 years ago

Added functionality to use only a subsection in the statistics calculations. This includes:

  • A new Section class.
  • New input parameters.
  • Altering the setCubeStats() function to test for this.
  • Some documentation on the new parameters.
File size: 1.8 KB
Line 
1#ifndef SECTION_H
2#define SECTION_H
3
4#include <string>
5#include <vector>
6
7/**
8 * A class to store information on subsections of a cube. This keeps
9 * the subsection itself as a string, plus the parsed information in
10 * the format of vectors of starting positions and lengths of each
11 * dimension.
12 */
13
14class Section
15{
16public:
17  Section(){numSections=0;};
18  Section(std::string &s){subsection=s;};
19  Section(const Section& s);
20  Section& operator= (const Section& s);
21  virtual ~Section(){};
22
23  /** Convert the subsection string into the lists of numerical values. */
24  int parse(std::vector<long> dimAxes);
25
26  /** Test whether a given voxel (x,y,z) lies within the subsection */
27  bool isInside(int x, int y, int z){
28    return (  ( (x>=starts[0])&&(x<starts[0]+dims[0])  ) &&
29              ( (y>=starts[1])&&(y<starts[1]+dims[1])  ) &&
30              ( (z>=starts[2])&&(z<starts[2]+dims[2])  )   );
31  }
32
33  /** Save the subsection string */
34  void setSection(std::string s){subsection=s;};
35  /** Return the subsection string */
36  std::string getSection(){return subsection;};
37
38  /** Return a particular starting value */
39  int getStart(int i){return starts[i];};
40  /** Return a particular dimension length */
41  int getDim(int i){return dims[i];};
42
43  /** Return the full list of start values */
44  std::vector<int> getStartList(){return starts;};
45  /** Return the full list of dimension lengths */
46  std::vector<int> getDimList(){return dims;};
47
48private:
49  std::string subsection;   ///< The string indicating the subsection,
50                            ///   of the format [a:b,c:d,e:f] etc.
51  int numSections;          ///< The number of sections in the string.
52  std::vector<int> starts;  ///< The list of starting values (a,c,e)
53  std::vector<int> dims;    ///< The list of lengths of each dimension
54                            ///   (b-a+1,d-c+1,f-e+1)
55};
56
57
58#endif //SECTION_H
Note: See TracBrowser for help on using the repository browser.