Isis 3.0 Programmer Reference
Back | Home
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 {
31  AlphaCube::AlphaCube(Cube &cube) {
32  Isis::PvlObject &isiscube = cube.label()->findObject("IsisCube");
33  if(isiscube.hasGroup("AlphaCube")) {
34  Isis::PvlGroup &alpha = isiscube.findGroup("AlphaCube");
35  p_alphaSamples = alpha["AlphaSamples"];
36  p_alphaLines = alpha["AlphaLines"];
37  p_alphaStartingSample = alpha["AlphaStartingSample"];
38  p_alphaStartingLine = alpha["AlphaStartingLine"];
39  p_alphaEndingSample = alpha["AlphaEndingSample"];
40  p_alphaEndingLine = alpha["AlphaEndingLine"];
41  p_betaSamples = alpha["BetaSamples"];
42  p_betaLines = alpha["BetaLines"];
43  }
44  else {
45  p_alphaSamples = cube.sampleCount();
46  p_alphaLines = cube.lineCount();
47  p_alphaStartingSample = 0.5;
48  p_alphaStartingLine = 0.5;
49  p_alphaEndingSample = (double) p_alphaSamples + 0.5;
50  p_alphaEndingLine = (double) p_alphaLines + 0.5;
51  p_betaSamples = p_alphaSamples;
52  p_betaLines = p_alphaLines;
53  }
54 
55  ComputeSlope();
56  }
57 
62  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
63  int betaSamples, int betaLines,
64  double alphaSs, double alphaSl,
65  double alphaEs, double alphaEl) {
66  p_alphaSamples = alphaSamples;
67  p_alphaLines = alphaLines;
68  p_alphaStartingSample = alphaSs;
69  p_alphaStartingLine = alphaSl;
70  p_alphaEndingSample = alphaEs;
71  p_alphaEndingLine = alphaEl;
72 
73  p_betaSamples = betaSamples;
74  p_betaLines = betaLines;
75 
76  ComputeSlope();
77  }
78 
82  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
83  int betaSamples, int betaLines) {
84  p_alphaSamples = alphaSamples;
85  p_alphaLines = alphaLines;
86  p_alphaStartingSample = 0.5;
87  p_alphaStartingLine = 0.5;
88  p_alphaEndingSample = (double) alphaSamples + 0.5;
89  p_alphaEndingLine = (double) alphaLines + 0.5;
90 
91  p_betaSamples = betaSamples;
92  p_betaLines = betaLines;
93 
94  ComputeSlope();
95  }
96 
103  void AlphaCube::Rehash(AlphaCube &add) {
104  double sl = AlphaLine(add.AlphaLine(0.5));
105  double ss = AlphaSample(add.AlphaSample(0.5));
106  double el = AlphaLine(add.AlphaLine(add.BetaLines() + 0.5));
107  double es = AlphaSample(add.AlphaSample(add.BetaSamples() + 0.5));
108 
109  p_alphaStartingLine = sl;
110  p_alphaStartingSample = ss;
111  p_alphaEndingLine = el;
112  p_alphaEndingSample = es;
113  p_betaLines = add.BetaLines();
114  p_betaSamples = add.BetaSamples();
115 
116  ComputeSlope();
117  }
118 
129  void AlphaCube::UpdateGroup(Isis::Cube &cube) {
130  // If we have a mapping group we do not want to update the alpha cube
131  // group as it represents the dimensions and sub-area of the raw instrument
132  // cube
133  Isis::PvlObject &cubeObject = cube.label()->findObject("IsisCube");
134  if(cubeObject.hasGroup("Mapping")) return;
135 
136  // Add the labels to the pvl
137  if(cubeObject.hasGroup("AlphaCube")) {
138  AlphaCube temp(cube);
139  temp.Rehash(*this);
140  *this = temp;
141 
142  Isis::PvlGroup &alpha = cubeObject.findGroup("AlphaCube");
143  alpha["AlphaSamples"] = toString(p_alphaSamples);
144  alpha["AlphaLines"] = toString(p_alphaLines);
145  alpha["AlphaStartingSample"] = toString(p_alphaStartingSample);
146  alpha["AlphaStartingLine"] = toString(p_alphaStartingLine);
147  alpha["AlphaEndingSample"] = toString(p_alphaEndingSample);
148  alpha["AlphaEndingLine"] = toString(p_alphaEndingLine);
149  alpha["BetaSamples"] = toString(p_betaSamples);
150  alpha["BetaLines"] = toString(p_betaLines);
151  }
152  else {
153  Isis::PvlGroup alpha("AlphaCube");
154  alpha += Isis::PvlKeyword("AlphaSamples", toString(p_alphaSamples));
155  alpha += Isis::PvlKeyword("AlphaLines", toString(p_alphaLines));
156  alpha += Isis::PvlKeyword("AlphaStartingSample", toString(p_alphaStartingSample));
157  alpha += Isis::PvlKeyword("AlphaStartingLine", toString(p_alphaStartingLine));
158  alpha += Isis::PvlKeyword("AlphaEndingSample", toString(p_alphaEndingSample));
159  alpha += Isis::PvlKeyword("AlphaEndingLine", toString(p_alphaEndingLine));
160  alpha += Isis::PvlKeyword("BetaSamples", toString(p_betaSamples));
161  alpha += Isis::PvlKeyword("BetaLines", toString(p_betaLines));
162  cubeObject.addGroup(alpha);
163  }
164  }
165 
173  void AlphaCube::ComputeSlope() {
174  p_lineSlope = double(p_alphaEndingLine - p_alphaStartingLine) /
175  double((p_betaLines + 0.5) - 0.5);
176  p_sampSlope = double(p_alphaEndingSample - p_alphaStartingSample) /
177  double((p_betaSamples + 0.5) - 0.5);
178  }
179 }
int BetaLines() const
Returns the number of lines in the beta cube.
Definition: AlphaCube.h:82
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
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
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1298
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:198
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:61
double AlphaLine(double betaLine)
Returns an alpha line given a beta line.
Definition: AlphaCube.h:90
int BetaSamples() const
Returns the number of samples in the beta cube.
Definition: AlphaCube.h:86
int sampleCount() const
Definition: Cube.cpp:1404
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
double AlphaSample(double betaSample)
Returns an alpha sample given a beta sample.
Definition: AlphaCube.h:94
A single keyword-value pair.
Definition: PvlKeyword.h:98
void Rehash(AlphaCube &alphaCube)
Merges two AlphaCube objects.
Definition: AlphaCube.cpp:103
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
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:74
int lineCount() const
Definition: Cube.cpp:1331
IO Handler for Isis Cubes.
Definition: Cube.h:158

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:14:08