Isis 3 Programmer Reference
AlphaCube.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "AlphaCube.h"
9 
10 #include "Cube.h"
11 
12 using namespace std;
13 
14 namespace Isis {
20  AlphaCube::AlphaCube(Cube &cube) {
21  Isis::PvlObject &isiscube = cube.label()->findObject("IsisCube");
22  if(isiscube.hasGroup("AlphaCube")) {
23  Isis::PvlGroup &alpha = isiscube.findGroup("AlphaCube");
24  p_alphaSamples = alpha["AlphaSamples"];
25  p_alphaLines = alpha["AlphaLines"];
26  p_alphaStartingSample = alpha["AlphaStartingSample"];
27  p_alphaStartingLine = alpha["AlphaStartingLine"];
28  p_alphaEndingSample = alpha["AlphaEndingSample"];
29  p_alphaEndingLine = alpha["AlphaEndingLine"];
30  p_betaSamples = alpha["BetaSamples"];
31  p_betaLines = alpha["BetaLines"];
32  }
33  else {
34  p_alphaSamples = cube.sampleCount();
35  p_alphaLines = cube.lineCount();
36  p_alphaStartingSample = 0.5;
37  p_alphaStartingLine = 0.5;
38  p_alphaEndingSample = (double) p_alphaSamples + 0.5;
39  p_alphaEndingLine = (double) p_alphaLines + 0.5;
40  p_betaSamples = p_alphaSamples;
41  p_betaLines = p_alphaLines;
42  }
43 
44  ComputeSlope();
45  }
46 
61  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
62  int betaSamples, int betaLines,
63  double alphaSs, double alphaSl,
64  double alphaEs, double alphaEl) {
65  p_alphaSamples = alphaSamples;
66  p_alphaLines = alphaLines;
67  p_alphaStartingSample = alphaSs;
68  p_alphaStartingLine = alphaSl;
69  p_alphaEndingSample = alphaEs;
70  p_alphaEndingLine = alphaEl;
71 
72  p_betaSamples = betaSamples;
73  p_betaLines = betaLines;
74 
75  ComputeSlope();
76  }
77 
87  AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
88  int betaSamples, int betaLines) {
89  p_alphaSamples = alphaSamples;
90  p_alphaLines = alphaLines;
91  p_alphaStartingSample = 0.5;
92  p_alphaStartingLine = 0.5;
93  p_alphaEndingSample = (double) alphaSamples + 0.5;
94  p_alphaEndingLine = (double) alphaLines + 0.5;
95 
96  p_betaSamples = betaSamples;
97  p_betaLines = betaLines;
98 
99  ComputeSlope();
100  }
101 
108  void AlphaCube::Rehash(AlphaCube &add) {
109  double sl = AlphaLine(add.AlphaLine(0.5));
110  double ss = AlphaSample(add.AlphaSample(0.5));
111  double el = AlphaLine(add.AlphaLine(add.BetaLines() + 0.5));
112  double es = AlphaSample(add.AlphaSample(add.BetaSamples() + 0.5));
113 
114  p_alphaStartingLine = sl;
115  p_alphaStartingSample = ss;
116  p_alphaEndingLine = el;
117  p_alphaEndingSample = es;
118  p_betaLines = add.BetaLines();
119  p_betaSamples = add.BetaSamples();
120 
121  ComputeSlope();
122  }
123 
134  void AlphaCube::UpdateGroup(Isis::Cube &cube) {
135  // If we have a mapping group we do not want to update the alpha cube
136  // group as it represents the dimensions and sub-area of the raw instrument
137  // cube
138  Isis::PvlObject &cubeObject = cube.label()->findObject("IsisCube");
139  if(cubeObject.hasGroup("Mapping")) return;
140 
141  // Add the labels to the pvl
142  if(cubeObject.hasGroup("AlphaCube")) {
143  AlphaCube temp(cube);
144  temp.Rehash(*this);
145  *this = temp;
146 
147  Isis::PvlGroup &alpha = cubeObject.findGroup("AlphaCube");
148  alpha["AlphaSamples"] = toString(p_alphaSamples);
149  alpha["AlphaLines"] = toString(p_alphaLines);
150  alpha["AlphaStartingSample"] = toString(p_alphaStartingSample);
151  alpha["AlphaStartingLine"] = toString(p_alphaStartingLine);
152  alpha["AlphaEndingSample"] = toString(p_alphaEndingSample);
153  alpha["AlphaEndingLine"] = toString(p_alphaEndingLine);
154  alpha["BetaSamples"] = toString(p_betaSamples);
155  alpha["BetaLines"] = toString(p_betaLines);
156  }
157  else {
158  Isis::PvlGroup alpha("AlphaCube");
159  alpha += Isis::PvlKeyword("AlphaSamples", toString(p_alphaSamples));
160  alpha += Isis::PvlKeyword("AlphaLines", toString(p_alphaLines));
161  alpha += Isis::PvlKeyword("AlphaStartingSample", toString(p_alphaStartingSample));
162  alpha += Isis::PvlKeyword("AlphaStartingLine", toString(p_alphaStartingLine));
163  alpha += Isis::PvlKeyword("AlphaEndingSample", toString(p_alphaEndingSample));
164  alpha += Isis::PvlKeyword("AlphaEndingLine", toString(p_alphaEndingLine));
165  alpha += Isis::PvlKeyword("BetaSamples", toString(p_betaSamples));
166  alpha += Isis::PvlKeyword("BetaLines", toString(p_betaLines));
167  cubeObject.addGroup(alpha);
168  }
169  }
170 
178  void AlphaCube::ComputeSlope() {
179  p_lineSlope = double(p_alphaEndingLine - p_alphaStartingLine) /
180  double((p_betaLines + 0.5) - 0.5);
181  p_sampSlope = double(p_alphaEndingSample - p_alphaStartingSample) /
182  double((p_betaSamples + 0.5) - 0.5);
183  }
184 }
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::PvlObject
Contains Pvl Groups and Pvl Objects.
Definition: PvlObject.h:61
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::AlphaCube::AlphaLine
double AlphaLine(double betaLine)
Returns an alpha line given a beta line.
Definition: AlphaCube.h:109
Isis::PvlObject::hasGroup
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
Definition: PvlObject.h:210
Isis::AlphaCube::AlphaSample
double AlphaSample(double betaSample)
Returns an alpha sample given a beta sample.
Definition: AlphaCube.h:121
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Cube::lineCount
int lineCount() const
Definition: Cube.cpp:1734
Isis::AlphaCube::BetaLines
int BetaLines() const
Returns the number of lines in the beta cube.
Definition: AlphaCube.h:87
Isis::PvlObject::findObject
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition: PvlObject.h:274
Isis::Cube::sampleCount
int sampleCount() const
Definition: Cube.cpp:1807
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::AlphaCube
This class is used to rewrite the "alpha" keywords out of the AlphaCube group or Instrument group.
Definition: AlphaCube.h:46
Isis::PvlObject::addGroup
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition: PvlObject.h:186
Isis::AlphaCube::BetaSamples
int BetaSamples() const
Returns the number of samples in the beta cube.
Definition: AlphaCube.h:97
std
Namespace for the standard library.
Isis::AlphaCube::Rehash
void Rehash(AlphaCube &alphaCube)
Merges two AlphaCube objects.
Definition: AlphaCube.cpp:108
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16