Isis 3 Programmer Reference
AlphaCube.cpp
Go to the documentation of this file.
1 
23 #include "AlphaCube.h"
24 
25 #include "Cube.h"
26 
27 using namespace std;
28 
29 namespace Isis {
35  AlphaCube::AlphaCube(Cube &cube) {
36  Isis::PvlObject &isiscube = cube.label()->findObject("IsisCube");
37  if(isiscube.hasGroup("AlphaCube")) {
38  Isis::PvlGroup &alpha = isiscube.findGroup("AlphaCube");
39  p_alphaSamples = alpha["AlphaSamples"];
40  p_alphaLines = alpha["AlphaLines"];
41  p_alphaStartingSample = alpha["AlphaStartingSample"];
42  p_alphaStartingLine = alpha["AlphaStartingLine"];
43  p_alphaEndingSample = alpha["AlphaEndingSample"];
44  p_alphaEndingLine = alpha["AlphaEndingLine"];
45  p_betaSamples = alpha["BetaSamples"];
46  p_betaLines = alpha["BetaLines"];
47  }
48  else {
49  p_alphaSamples = cube.sampleCount();
50  p_alphaLines = cube.lineCount();
51  p_alphaStartingSample = 0.5;
52  p_alphaStartingLine = 0.5;
53  p_alphaEndingSample = (double) p_alphaSamples + 0.5;
54  p_alphaEndingLine = (double) p_alphaLines + 0.5;
55  p_betaSamples = p_alphaSamples;
56  p_betaLines = p_alphaLines;
57  }
58 
59  ComputeSlope();
60  }
61 
76  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
77  int betaSamples, int betaLines,
78  double alphaSs, double alphaSl,
79  double alphaEs, double alphaEl) {
80  p_alphaSamples = alphaSamples;
81  p_alphaLines = alphaLines;
82  p_alphaStartingSample = alphaSs;
83  p_alphaStartingLine = alphaSl;
84  p_alphaEndingSample = alphaEs;
85  p_alphaEndingLine = alphaEl;
86 
87  p_betaSamples = betaSamples;
88  p_betaLines = betaLines;
89 
90  ComputeSlope();
91  }
92 
102  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
103  int betaSamples, int betaLines) {
104  p_alphaSamples = alphaSamples;
105  p_alphaLines = alphaLines;
106  p_alphaStartingSample = 0.5;
107  p_alphaStartingLine = 0.5;
108  p_alphaEndingSample = (double) alphaSamples + 0.5;
109  p_alphaEndingLine = (double) alphaLines + 0.5;
110 
111  p_betaSamples = betaSamples;
112  p_betaLines = betaLines;
113 
114  ComputeSlope();
115  }
116 
123  void AlphaCube::Rehash(AlphaCube &add) {
124  double sl = AlphaLine(add.AlphaLine(0.5));
125  double ss = AlphaSample(add.AlphaSample(0.5));
126  double el = AlphaLine(add.AlphaLine(add.BetaLines() + 0.5));
127  double es = AlphaSample(add.AlphaSample(add.BetaSamples() + 0.5));
128 
129  p_alphaStartingLine = sl;
130  p_alphaStartingSample = ss;
131  p_alphaEndingLine = el;
132  p_alphaEndingSample = es;
133  p_betaLines = add.BetaLines();
134  p_betaSamples = add.BetaSamples();
135 
136  ComputeSlope();
137  }
138 
149  void AlphaCube::UpdateGroup(Isis::Cube &cube) {
150  // If we have a mapping group we do not want to update the alpha cube
151  // group as it represents the dimensions and sub-area of the raw instrument
152  // cube
153  Isis::PvlObject &cubeObject = cube.label()->findObject("IsisCube");
154  if(cubeObject.hasGroup("Mapping")) return;
155 
156  // Add the labels to the pvl
157  if(cubeObject.hasGroup("AlphaCube")) {
158  AlphaCube temp(cube);
159  temp.Rehash(*this);
160  *this = temp;
161 
162  Isis::PvlGroup &alpha = cubeObject.findGroup("AlphaCube");
163  alpha["AlphaSamples"] = toString(p_alphaSamples);
164  alpha["AlphaLines"] = toString(p_alphaLines);
165  alpha["AlphaStartingSample"] = toString(p_alphaStartingSample);
166  alpha["AlphaStartingLine"] = toString(p_alphaStartingLine);
167  alpha["AlphaEndingSample"] = toString(p_alphaEndingSample);
168  alpha["AlphaEndingLine"] = toString(p_alphaEndingLine);
169  alpha["BetaSamples"] = toString(p_betaSamples);
170  alpha["BetaLines"] = toString(p_betaLines);
171  }
172  else {
173  Isis::PvlGroup alpha("AlphaCube");
174  alpha += Isis::PvlKeyword("AlphaSamples", toString(p_alphaSamples));
175  alpha += Isis::PvlKeyword("AlphaLines", toString(p_alphaLines));
176  alpha += Isis::PvlKeyword("AlphaStartingSample", toString(p_alphaStartingSample));
177  alpha += Isis::PvlKeyword("AlphaStartingLine", toString(p_alphaStartingLine));
178  alpha += Isis::PvlKeyword("AlphaEndingSample", toString(p_alphaEndingSample));
179  alpha += Isis::PvlKeyword("AlphaEndingLine", toString(p_alphaEndingLine));
180  alpha += Isis::PvlKeyword("BetaSamples", toString(p_betaSamples));
181  alpha += Isis::PvlKeyword("BetaLines", toString(p_betaLines));
182  cubeObject.addGroup(alpha);
183  }
184  }
185 
193  void AlphaCube::ComputeSlope() {
194  p_lineSlope = double(p_alphaEndingLine - p_alphaStartingLine) /
195  double((p_betaLines + 0.5) - 0.5);
196  p_sampSlope = double(p_alphaEndingSample - p_alphaStartingSample) /
197  double((p_betaSamples + 0.5) - 0.5);
198  }
199 }
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
int BetaLines() const
Returns the number of lines in the beta cube.
Definition: AlphaCube.h:103
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:286
int sampleCount() const
Definition: Cube.cpp:1452
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:198
Namespace for the standard library.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
Definition: PvlObject.h:222
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
This class is used to rewrite the "alpha" keywords out of the AlphaCube group or Instrument group...
Definition: AlphaCube.h:62
double AlphaLine(double betaLine)
Returns an alpha line given a beta line.
Definition: AlphaCube.h:125
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
double AlphaSample(double betaSample)
Returns an alpha sample given a beta sample.
Definition: AlphaCube.h:137
A single keyword-value pair.
Definition: PvlKeyword.h:98
int BetaSamples() const
Returns the number of samples in the beta cube.
Definition: AlphaCube.h:113
void Rehash(AlphaCube &alphaCube)
Merges two AlphaCube objects.
Definition: AlphaCube.cpp:123
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
int lineCount() const
Definition: Cube.cpp:1379
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
IO Handler for Isis Cubes.
Definition: Cube.h:170