Isis 3 Programmer Reference
|
Calculator for arrays. More...
#include <CubeCalculator.h>
Public Member Functions | |
CubeCalculator () | |
Constructs a CubeCalculator. More... | |
~CubeCalculator () | |
Destroys the CubeCalculator object. More... | |
void | Clear () |
This method completely resets the calculator. More... | |
void | prepareCalculations (QString equation, QVector< Cube *> &inCubes, Cube *outCube) |
This method builds a list of actions to perform based on the postfix expression. More... | |
QVector< double > | runCalculations (QVector< Buffer *> &cubeData, int line, int band) |
This method will execute the calculations built up when PrepareCalculations was called. More... | |
Private Types | |
enum | Calculations { CallNextMethod, PushNextData } |
This is used to define the overall action to perform in RunCalculations(..). More... | |
Private Member Functions | |
void | addMethodCall (void(Calculator::*method)(void)) |
This is a conveinience method for PrepareCalculations(...). More... | |
int | lastPushToCubeStats (QVector< Cube *> &inCubes) |
Creates statistics internally for the last cube data pushed to the data definitions. More... | |
int | lastPushToCubeCameras (QVector< Cube *> &inCubes) |
Creates internal camera for the last pushed cube data. More... | |
void | Negative () |
Pops an element, negates it, then pushes the result. More... | |
void | Multiply () |
Pops two elements, multiplies them, then pushes the product on the stack. More... | |
void | Add () |
Pops two elements, adds them, then pushes the sum on the stack. More... | |
void | Subtract () |
Pops two elements, subtracts them, then pushes the difference on the stack. More... | |
void | Divide () |
Pops two, divides them, then pushes the quotient on the stack. More... | |
void | Modulus () |
Pops two elements, mods them, then pushes the result on the stack. More... | |
void | Exponent () |
Pops two elements, computes the power then pushes the result on the stack The exponent has to be a scalar. More... | |
void | SquareRoot () |
Pop an element, compute its square root, then push the root on the stack. More... | |
void | AbsoluteValue () |
Pop an element, compute its absolute value, then push the result on the stack. More... | |
void | Log () |
Pop an element, compute its log, then push the result on the stack. More... | |
void | Log10 () |
Pop an element, compute its base 10 log, then push the result on the stack. More... | |
void | LeftShift () |
Pop the top element, then perform a left shift with zero fill. More... | |
void | RightShift () |
Pop the top element, then perform a right shift with zero fill. More... | |
void | MinimumPixel () |
Pop two elements, then push the minimum on a pixel by pixel basis back on the stack. More... | |
void | MaximumPixel () |
Pop two elements, then push the maximum on a pixel by pixel basis back on the stack. More... | |
void | MinimumLine () |
Pop one element, then push the minimum on the stack. More... | |
void | MaximumLine () |
Pop one element, then push the maximum on the stack. More... | |
void | Minimum2 () |
Not implemented in Calculator.cpp. More... | |
void | Maximum2 () |
Not implemented in Calculator.cpp. More... | |
void | GreaterThan () |
Pop two elements off the stack and compare them to see where one is greater than the other, then push the results on the stack. More... | |
void | LessThan () |
Pop two elements off the stack and compare them to see where one is less than the other, then push the results on the stack. More... | |
void | Equal () |
Pop two elements off the stack and compare them to see where one is equal to the other, then push the results on the stack. More... | |
void | LessThanOrEqual () |
Pop two elements off the stack and compare them to see where one is less than or equal to the other, then push the results on the stack. More... | |
void | GreaterThanOrEqual () |
Pop two elements off the stack and compare them to see where one is greater than or equal to the other, then push the results on the stack. More... | |
void | NotEqual () |
Pop two elements off the stack and compare them to see where one is not equal to the other, then push the results on the stack. More... | |
void | And () |
Pop two elements, AND them, then push the result on the stack. More... | |
void | Or () |
Pop two elements, OR them, then push the result on the stack. More... | |
void | Sine () |
Pops one element and push the sine. More... | |
void | Cosine () |
Pops one element and push the cosine. More... | |
void | Tangent () |
Pops one element and push the tangent. More... | |
void | Secant () |
Pops one element and push the secant. More... | |
void | Cosecant () |
Pops one element and push the cosecant. More... | |
void | Cotangent () |
Pops one element and push the cotangent. More... | |
void | Arcsine () |
Pops one element and push the arcsine. More... | |
void | Arccosine () |
Pops one element and push the arccosine. More... | |
void | Arctangent () |
Pops one element and push the arctangent. More... | |
void | Arctangent2 () |
Pops two elements and push the arctangent. More... | |
void | SineH () |
Pops one element and push the hyperbolic sine. More... | |
void | CosineH () |
Pops one element and push the hyperbolic cosine. More... | |
void | TangentH () |
Pops one element and push the hyperbolic tangent. More... | |
void | ArcsineH () |
Pops one element and push the inverse hyperbolic sine. More... | |
void | ArccosineH () |
Pops one element and push the inverse hyperbolic cosine. More... | |
void | ArctangentH () |
Pops one element and push the inverse hyperbolic tangent. More... | |
void | Push (double scalar) |
Push a scalar onto the stack. More... | |
void | Push (Buffer &buff) |
Push a buffer onto the stack. More... | |
void | Push (QVector< double > &vect) |
Push a vector onto the stack. More... | |
QVector< double > | Pop (bool keepSpecials=false) |
Pop an element off the stack. More... | |
void | PrintTop () |
Print the vector at the top of the stack. More... | |
bool | Empty () |
Check if the stack is empty. More... | |
void | PerformOperation (QVector< double > &results, QVector< double >::iterator arg1Start, QVector< double >::iterator arg1End, double operation(double)) |
Performs the mathematical operations on each argument. More... | |
void | PerformOperation (QVector< double > &results, QVector< double >::iterator arg1Start, QVector< double >::iterator arg1End, QVector< double >::iterator arg2Start, QVector< double >::iterator arg2End, double operation(double, double)) |
Performs the mathematical operation on each pair of arguments, or a set of agruments against a single argument. More... | |
int | StackSize () |
Returns the current stack size. More... | |
Private Attributes | |
QVector< Calculations > * | m_calculations |
This is what RunCalculations(...) will loop over. More... | |
QVector< void(Calculator::*)(void)> * | m_methods |
This stores the addresses to the methods RunCalculations(...) will call. More... | |
QVector< DataValue > * | m_dataDefinitions |
This defines what kind of data RunCalculations(...) will push onto the calculator. More... | |
QVector< Statistics * > * | m_cubeStats |
Stores the cube statistics for the input cubes. More... | |
QVector< Camera * > * | m_cubeCameras |
Stores the cameras for the input cubes. More... | |
QVector< CameraBuffers * > * | m_cameraBuffers |
Stores the camera buffers that are enabled for camera related calculations. More... | |
int | m_outputSamples |
Number of samples in the output cube. More... | |
Calculator for arrays.
This class is a RPN calculator on cubes. The base Calculator class is used in conjunction with methods to retrieve data from a cube and perform calculations.
2008-05-12 Steven Lambright - Removed references to CubeInfo
2008-06-18 Steven Lambright - Fixed documentation
2009-03-03 Steven Lambright - Added missing secant method call
2010-02-23 Steven Lambright - Added min2,max2
2010-04-08 Steven Lambright - Replaced min2,max with proper implementations of cubemin, cubemax, linemin, linemax, min and max. Added support for getting statistics of a cube for constants.
2012-02-02 Jeff Anderson - Added support for camera parameters such as phase, incidence, etc
2012-02-09 Jeff Anderson - Modified to conform to ISIS coding standards
2015-01-30 Ian Humphrey - Removed unused variable m_data. Deallocated unfreed dynamic memory. Added destructor. Fixes #2082.
2016-10-13 Ian Humphrey - Updated to correctly calculate center camera angles for band-depedent images. Integrated Moses Milazzo's (moses) changes for correctly calculating camera angles for band-dependent images. Quick documentation and coding standards review (moved inline implementations to cpp). Fixes #1301. @usg s.gov
Definition at line 72 of file CubeCalculator.h.
|
private |
This is used to define the overall action to perform in RunCalculations(..).
Enumerator | |
---|---|
CallNextMethod | The calculation requires calling one of the methods. |
PushNextData | The calculation requires input data. |
Definition at line 96 of file CubeCalculator.h.
Isis::CubeCalculator::CubeCalculator | ( | ) |
Constructs a CubeCalculator.
Definition at line 37 of file CubeCalculator.cpp.
Isis::CubeCalculator::~CubeCalculator | ( | ) |
Destroys the CubeCalculator object.
Definition at line 57 of file CubeCalculator.cpp.
|
inherited |
Pop an element, compute its absolute value, then push the result on the stack.
Definition at line 422 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two elements, adds them, then pushes the sum on the stack.
Definition at line 345 of file Calculator.cpp.
References Isis::AddOperator().
Referenced by Isis::InlineCalculator::initialize().
|
private |
This is a conveinience method for PrepareCalculations(...).
This will cause RunCalculations(...) to execute this method in order.
method | The method to call, i.e. &Calculator::Multiply |
Definition at line 843 of file CubeCalculator.cpp.
|
inherited |
Pop two elements, AND them, then push the result on the stack.
Definition at line 694 of file Calculator.cpp.
References Isis::BitwiseAndOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the arccosine.
Definition at line 792 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the inverse hyperbolic cosine.
Definition at line 822 of file Calculator.cpp.
|
inherited |
Pops one element and push the arcsine.
Definition at line 782 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the inverse hyperbolic sine.
Definition at line 812 of file Calculator.cpp.
|
inherited |
Pops one element and push the arctangent.
Definition at line 802 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two elements and push the arctangent.
Definition at line 842 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the inverse hyperbolic tangent.
Definition at line 832 of file Calculator.cpp.
|
virtual |
This method completely resets the calculator.
Frees dynamic memory in container members.
The prepared calculations will be erased when this is called.
Reimplemented from Isis::Calculator.
Definition at line 79 of file CubeCalculator.cpp.
|
inherited |
Pops one element and push the cosecant.
Definition at line 752 of file Calculator.cpp.
References Isis::CosecantOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the cosine.
Definition at line 732 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the hyperbolic cosine.
Definition at line 865 of file Calculator.cpp.
|
inherited |
Pops one element and push the cotangent.
Definition at line 772 of file Calculator.cpp.
References Isis::CotangentOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two, divides them, then pushes the quotient on the stack.
Definition at line 369 of file Calculator.cpp.
References Isis::DivideOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Check if the stack is empty.
Definition at line 1028 of file Calculator.cpp.
|
inherited |
Pop two elements off the stack and compare them to see where one is equal to the other, then push the results on the stack.
Definition at line 632 of file Calculator.cpp.
References Isis::EqualOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two elements, computes the power then pushes the result on the stack The exponent has to be a scalar.
Isis::iException::Math |
Definition at line 397 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements off the stack and compare them to see where one is greater than the other, then push the results on the stack.
Definition at line 602 of file Calculator.cpp.
References Isis::GreaterThanOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements off the stack and compare them to see where one is greater than or equal to the other, then push the results on the stack.
Definition at line 647 of file Calculator.cpp.
References Isis::GreaterThanOrEqualOperator().
Referenced by Isis::InlineCalculator::initialize().
Creates internal camera for the last pushed cube data.
This method is used to set up cameras for the input cubes.
IException::Unknown | "Not sure which files to get cameras from" |
IException::Unknown | "This function must not contain calcuations, only input cubes may be specified." |
IException::Unknown | "This function must not contain constants, only input cubes may be specified." |
IException::Unknown | "This function requires a camera and the input cube does not have one. You may need to run spiceinit" |
IException::Unknown | "This function requires a camera and the input cube does not have one. You may need to run spiceinit" |
Definition at line 774 of file CubeCalculator.cpp.
References _FILEINFO_, Isis::DataValue::cubeIndex(), and Isis::DataValue::type().
Creates statistics internally for the last cube data pushed to the data definitions.
This method is used for setting up internal statistics for the input cubes. This allows access to the statistics for each of the input cube when adding statistics related values to the calculator.
IException::Unknown | "This function must not contain constants, only input cubes may be specified" |
Definition at line 714 of file CubeCalculator.cpp.
References _FILEINFO_, Isis::DataValue::cubeIndex(), and Isis::DataValue::type().
|
inherited |
Pop the top element, then perform a left shift with zero fill.
Isis::iException::Math |
Definition at line 456 of file Calculator.cpp.
References _FILEINFO_.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements off the stack and compare them to see where one is less than the other, then push the results on the stack.
Definition at line 617 of file Calculator.cpp.
References Isis::LessThanOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements off the stack and compare them to see where one is less than or equal to the other, then push the results on the stack.
Definition at line 662 of file Calculator.cpp.
References Isis::LessThanOrEqualOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop an element, compute its log, then push the result on the stack.
Isis::iException::Math |
Definition at line 434 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop an element, compute its base 10 log, then push the result on the stack.
Definition at line 444 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Not implemented in Calculator.cpp.
|
inherited |
Pop one element, then push the maximum on the stack.
Definition at line 552 of file Calculator.cpp.
References Isis::IsSpecial().
|
inherited |
Pop two elements, then push the maximum on a pixel by pixel basis back on the stack.
Definition at line 587 of file Calculator.cpp.
References Isis::MaximumOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Not implemented in Calculator.cpp.
|
inherited |
Pop one element, then push the minimum on the stack.
Definition at line 533 of file Calculator.cpp.
References Isis::IsSpecial().
|
inherited |
Pop two elements, then push the minimum on a pixel by pixel basis back on the stack.
Definition at line 572 of file Calculator.cpp.
References Isis::MinimumOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two elements, mods them, then pushes the result on the stack.
Definition at line 381 of file Calculator.cpp.
References Isis::ModulusOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops two elements, multiplies them, then pushes the product on the stack.
Definition at line 332 of file Calculator.cpp.
References Isis::MultiplyOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops an element, negates it, then pushes the result.
Definition at line 322 of file Calculator.cpp.
References Isis::NegateOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements off the stack and compare them to see where one is not equal to the other, then push the results on the stack.
Definition at line 677 of file Calculator.cpp.
References Isis::NotEqualOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pop two elements, OR them, then push the result on the stack.
Definition at line 708 of file Calculator.cpp.
References Isis::BitwiseOrOperator().
Referenced by Isis::InlineCalculator::initialize().
|
protectedinherited |
Performs the mathematical operations on each argument.
results | [out] The results of the performed operation |
arg1Start | The first argument to have the operation done on |
arg1End | One argument beyond the final argument to have the operation done upon |
operation | The operation to be done on all arguments |
Definition at line 1052 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::floatModulus().
|
protectedinherited |
Performs the mathematical operation on each pair of arguments, or a set of agruments against a single argument.
results | [out] The results of the performed operation |
arg1Start | The first of the primary argument to have the operation done on |
arg1End | One arguement beyond the final primary argument to have the operation done upon |
arg2Start | The first of the secondaty argument to have the operation done on |
arg2End | One arguement beyond the final secondary argument to have the operation done upon |
operation | The operation to be done on all pairs of arguments |
Definition at line 1081 of file Calculator.cpp.
References _FILEINFO_.
|
inherited |
Pop an element off the stack.
keepSpecials | If true, special pixels will be preserved; otherwise, they will be mapped to double values |
Definition at line 964 of file Calculator.cpp.
References _FILEINFO_, Isis::Hrs, Isis::Lrs, and Isis::Null.
Referenced by Isis::InlineCalculator::degrees(), Isis::InlineCalculator::evaluate(), Isis::InlineCalculator::floatModulus(), Isis::InlineCalculator::logicalAnd(), Isis::InlineCalculator::logicalOr(), and Isis::InlineCalculator::radians().
void Isis::CubeCalculator::prepareCalculations | ( | QString | equation, |
QVector< Cube *> & | inCubes, | ||
Cube * | outCube | ||
) |
This method builds a list of actions to perform based on the postfix expression.
Error checking is done using the inCubeInfos, and the outCubeInfo is necessary to tell the dimensions of the output cube. Call this method before calling RunCalculations(). This method will also erase all calculator history before building up a new set of calculations to run.
equation | The equation in postfix notation |
inCubes | The input cubes |
outCube | The output cube |
IException::Unknown | "Invalid file number" |
IException::Unknown | "Unidentified operator" |
Definition at line 264 of file CubeCalculator.cpp.
References _FILEINFO_, Isis::E, Isis::PI, Isis::Cube::sampleCount(), Isis::IString::ToDouble(), Isis::IString::ToInteger(), and Isis::IString::Token().
|
inherited |
Print the vector at the top of the stack.
Definition at line 1004 of file Calculator.cpp.
|
inherited |
Push a scalar onto the stack.
scalar | The scalar that will be pushed on the stack |
Definition at line 908 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::degrees(), Isis::InlineCalculator::eConstant(), Isis::InlineCalculator::floatModulus(), Isis::InlineCalculator::logicalAnd(), Isis::InlineCalculator::logicalOr(), Isis::InlineCalculator::pi(), Isis::InlineCalculator::radians(), Isis::InlineCalculator::scalar(), and Isis::InlineCalculator::variable().
|
inherited |
Push a buffer onto the stack.
buff | The buffer that will be pushed on the stack |
Definition at line 920 of file Calculator.cpp.
References Isis::IsHisPixel(), Isis::IsHrsPixel(), Isis::IsLisPixel(), Isis::IsLrsPixel(), Isis::IsNullPixel(), Isis::IsSpecial(), and Isis::Buffer::size().
|
inherited |
Push a vector onto the stack.
vect | The vector that will be pushed on the stack |
Definition at line 898 of file Calculator.cpp.
|
inherited |
Pop the top element, then perform a right shift with zero fill.
Isis::iException::Math |
Definition at line 495 of file Calculator.cpp.
References _FILEINFO_.
Referenced by Isis::InlineCalculator::initialize().
QVector< double > Isis::CubeCalculator::runCalculations | ( | QVector< Buffer *> & | cubeData, |
int | curLine, | ||
int | curBand | ||
) |
This method will execute the calculations built up when PrepareCalculations was called.
cubeData | The input cubes' data |
curLine | The current line in the output cube |
curBand | The current band in the output cube |
IException::Unknown | "Too many operands in the equation." |
Definition at line 129 of file CubeCalculator.cpp.
References _FILEINFO_, Isis::DataValue::constant(), Isis::DataValue::cubeIndex(), and Isis::DataValue::type().
|
inherited |
Pops one element and push the secant.
Definition at line 762 of file Calculator.cpp.
References Isis::SecantOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the sine.
Definition at line 722 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the hyperbolic sine.
Definition at line 855 of file Calculator.cpp.
|
inherited |
Pop an element, compute its square root, then push the root on the stack.
Isis::iException::Math |
Definition at line 412 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
protectedinherited |
Returns the current stack size.
Get the current stack size.
Definition at line 889 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::evaluate().
|
inherited |
Pops two elements, subtracts them, then pushes the difference on the stack.
Definition at line 357 of file Calculator.cpp.
References Isis::SubtractOperator().
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the tangent.
Definition at line 742 of file Calculator.cpp.
Referenced by Isis::InlineCalculator::initialize().
|
inherited |
Pops one element and push the hyperbolic tangent.
Definition at line 875 of file Calculator.cpp.
|
private |
This is what RunCalculations(...) will loop over.
The action to perform (push data or execute calculation) is defined in this vector.
Definition at line 114 of file CubeCalculator.h.
|
private |
Stores the camera buffers that are enabled for camera related calculations.
This is used for quickly computing camera related information.
Definition at line 135 of file CubeCalculator.h.
Stores the cameras for the input cubes.
This is synchronized with m_cameraBuffers so that the camera buffers are loaded with data from the appropriate camera.
Definition at line 129 of file CubeCalculator.h.
|
private |
Stores the cube statistics for the input cubes.
Definition at line 123 of file CubeCalculator.h.
This defines what kind of data RunCalculations(...) will push onto the calculator.
Definition at line 120 of file CubeCalculator.h.
|
private |
This stores the addresses to the methods RunCalculations(...) will call.
Definition at line 117 of file CubeCalculator.h.
|
private |
Number of samples in the output cube.
Definition at line 137 of file CubeCalculator.h.