File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
Enlarge.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Enlarge.h"
8
9#include <cmath>
10
11#include "Cube.h"
12#include "IException.h"
13#include "PvlGroup.h"
14#include "SubArea.h"
15
16using namespace std;
17
18namespace Isis {
19
27 Enlarge::Enlarge(Cube *pInCube, const double sampleScale,
28 const double lineScale) {
29 // Input Cube
30 mInCube = pInCube;
31
32 // Set input image area to defaults
33 mdStartSample = 1;
34 mdEndSample = mInCube->sampleCount();
35 mdStartLine = 1;
36 mdEndLine = mInCube->lineCount();
37
38 // Save off the sample and line magnification
39 mdSampleScale = sampleScale;
40 mdLineScale = lineScale;
41
42 miOutputSamples = (int)ceil(mInCube->sampleCount() * mdSampleScale);
43 miOutputLines = (int)ceil(mInCube->lineCount() * mdLineScale);
44 }
45
57 bool Enlarge::Xform(double &inSample, double &inLine,
58 const double outSample, const double outLine) {
59 inSample = (outSample - 0.5) / mdSampleScale + 0.5 + (mdStartSample - 1);
60 inLine = (outLine - 0.5) / mdLineScale + 0.5 + (mdStartLine - 1);
61
62 return true;
63 }
64
76 void Enlarge::SetInputArea(double pdStartSample, double pdEndSample,
77 double pdStartLine, double pdEndLine) {
78 // Check for the right image dimensions
79 if (pdStartSample > pdEndSample || pdStartLine > pdEndLine) {
80 string sErrMsg = "Error in Input Area Dimesions";
81 throw IException(IException::Programmer, sErrMsg, _FILEINFO_);
82 }
83
84 if (pdStartSample >= 1) {
85 mdStartSample = pdStartSample;
86 }
87 if (pdEndSample <= mInCube->sampleCount()) {
88 mdEndSample = pdEndSample;
89 }
90 if (pdStartLine >= 1) {
91 mdStartLine = pdStartLine;
92 }
93 if (pdEndLine <= mInCube->lineCount()) {
94 mdEndLine = pdEndLine;
95 }
96
98 miOutputLines = (int)ceil((mdEndLine - mdStartLine + 1) * mdLineScale);
99 }
100
115 int iNumSamples= mInCube->sampleCount();
116 int iNumLines = mInCube->lineCount();
117 // Construct a label with the results
118 // This is the Results group that will go into the application
119 // log file. This group must be created by the calling application.
120 // Information will be added to it if the Mapping or Instrument
121 // groups are deleted from the output image label
122 PvlGroup resultsGrp("Results");
123 resultsGrp += PvlKeyword("InputLines", toString(iNumLines));
124 resultsGrp += PvlKeyword("InputSamples", toString(iNumSamples));
125 resultsGrp += PvlKeyword("StartingLine", toString((int)mdStartLine));
126 resultsGrp += PvlKeyword("StartingSample", toString((int)mdStartSample));
127 resultsGrp += PvlKeyword("EndingLine", toString((int)mdEndLine));
128 resultsGrp += PvlKeyword("EndingSample", toString((int)mdEndSample));
129 resultsGrp += PvlKeyword("LineIncrement", toString(1. / mdLineScale));
130 resultsGrp += PvlKeyword("SampleIncrement", toString(1. / mdSampleScale));
131 resultsGrp += PvlKeyword("OutputLines", toString(miOutputLines));
132 resultsGrp += PvlKeyword("OutputSamples", toString(miOutputSamples));
133
134 SubArea subArea;
135 subArea.SetSubArea(mInCube->lineCount(), mInCube->sampleCount(), (int)mdStartLine, (int)mdStartSample,
136 (int)mdEndLine, (int)mdEndSample, 1.0 / mdLineScale, 1.0 / mdSampleScale);
137 subArea.UpdateLabel(mInCube, pOutCube, resultsGrp);
138
139 return resultsGrp;
140 }
141}
142
143
IO Handler for Isis Cubes.
Definition Cube.h:168
double mdStartSample
Input start sample.
Definition Enlarge.h:76
Cube * mInCube
Input image.
Definition Enlarge.h:71
void SetInputArea(double pdStartSample, double pdEndSample, double pdStartLine, double pdEndLine)
Sets the sub area dimensions of the input image.
Definition Enlarge.cpp:76
double mdEndLine
Input end line.
Definition Enlarge.h:79
double mdEndSample
Input end sample.
Definition Enlarge.h:77
bool Xform(double &inSample, double &inLine, const double outSample, const double outLine)
Implementations for parent's pure virtual members Convert the requested output samp/line to an input ...
Definition Enlarge.cpp:57
Enlarge(Cube *pInCube, const double sampleScale, const double lineScale)
Constructs an Enlarge object.
Definition Enlarge.cpp:27
double mdSampleScale
Sample scale.
Definition Enlarge.h:74
int miOutputLines
Number of lines for output.
Definition Enlarge.h:73
double mdStartLine
Input start line.
Definition Enlarge.h:78
int miOutputSamples
Number of samples for output.
Definition Enlarge.h:72
PvlGroup UpdateOutputLabel(Cube *pOutCube)
Update the Mapping, Instrument, and AlphaCube groups in the output cube label.
Definition Enlarge.cpp:114
double mdLineScale
Line scale.
Definition Enlarge.h:75
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
Contains multiple PvlContainers.
Definition PvlGroup.h:41
A single keyword-value pair.
Definition PvlKeyword.h:87
Apply corrections to a cube label for subarea extraction.
Definition SubArea.h:47
void UpdateLabel(Cube *icube, Cube *ocube, PvlGroup &results)
Modifies a label for a file containing a subarea.
Definition SubArea.cpp:126
void SetSubArea(const int orignl, const int origns, const int sl, const int ss, const int el, const int es, const double linc, const double sinc)
Defines the subarea.
Definition SubArea.cpp:60
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.