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
12using namespace std;
13
14namespace Isis {
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 {
35 p_alphaLines = cube.lineCount();
38 p_alphaEndingSample = (double) p_alphaSamples + 0.5;
39 p_alphaEndingLine = (double) p_alphaLines + 0.5;
42 }
43
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
76 }
77
87 AlphaCube::AlphaCube(int alphaSamples, int alphaLines,
88 int betaSamples, int betaLines) {
89 p_alphaSamples = alphaSamples;
90 p_alphaLines = alphaLines;
93 p_alphaEndingSample = (double) alphaSamples + 0.5;
94 p_alphaEndingLine = (double) alphaLines + 0.5;
95
96 p_betaSamples = betaSamples;
97 p_betaLines = betaLines;
98
100 }
101
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
118 p_betaLines = add.BetaLines();
120
121 ComputeSlope();
122 }
123
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
180 double((p_betaLines + 0.5) - 0.5);
182 double((p_betaSamples + 0.5) - 0.5);
183 }
184}
This class is used to rewrite the "alpha" keywords out of the AlphaCube group or Instrument group.
Definition AlphaCube.h:46
double p_alphaStartingLine
The starting alpha line.
Definition AlphaCube.h:159
void UpdateGroup(Cube &cube)
Writes or update the Alpha keywords (AlphaLines, AlphaSamples, AlphaStartingSamples,...
int p_alphaSamples
The number of alpha samples in the cube.
Definition AlphaCube.h:156
void ComputeSlope()
Computes the line and sample slopes.
double AlphaSample(double betaSample)
Returns an alpha sample given a beta sample.
Definition AlphaCube.h:121
int p_betaSamples
The number of beta samples in the cube.
Definition AlphaCube.h:158
double p_alphaEndingSample
The ending alpha sample.
Definition AlphaCube.h:162
double p_sampSlope
The slope of the sample set.
Definition AlphaCube.h:164
void Rehash(AlphaCube &alphaCube)
Merges two AlphaCube objects.
int BetaLines() const
Returns the number of lines in the beta cube.
Definition AlphaCube.h:87
AlphaCube(Cube &cube)
Constructs an AlphaCube object using a PVL object.
Definition AlphaCube.cpp:20
int p_betaLines
The number of beta lines in the cube.
Definition AlphaCube.h:157
double p_alphaStartingSample
The starting alpha sample.
Definition AlphaCube.h:160
double p_alphaEndingLine
The ending alpha line.
Definition AlphaCube.h:161
double p_lineSlope
The slope of the line.
Definition AlphaCube.h:163
double AlphaLine(double betaLine)
Returns an alpha line given a beta line.
Definition AlphaCube.h:109
int p_alphaLines
The number of alpha lines in the cube.
Definition AlphaCube.h:155
int BetaSamples() const
Returns the number of samples in the beta cube.
Definition AlphaCube.h:97
IO Handler for Isis Cubes.
Definition Cube.h:168
int lineCount() const
Definition Cube.cpp:1740
int sampleCount() const
Definition Cube.cpp:1813
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Contains multiple PvlContainers.
Definition PvlGroup.h:41
A single keyword-value pair.
Definition PvlKeyword.h:87
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition PvlObject.h:276
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.