9#include "ProcessByBrick.h"
25 p_outputRequirements = 0;
60 int allRequirements = AllMatchOrOne;
61 allRequirements |= requirements;
89 int allRequirements = AllMatchOrOne;
90 allRequirements |= requirements;
95void ProcessByBrick::SetOutputRequirements(
int outputRequirements) {
97 p_outputRequirements = outputRequirements;
102 void ProcessByBrick::SetBricks(IOCubes cn){
128 string m =
"You can only specify exactly one input or output cube";
133 string m =
"You haven't specified an input or output cube";
143 string m =
"You must specify exactly one input cube";
147 string m =
"You must specify exactly one output cube";
153 string m =
"The number of lines in the input and output cubes ";
159 string m =
"The number of samples in the input and output cubes ";
170 if ( !(p_outputRequirements & Isis::SpatialMatch ) ) {
172 string m =
"The number of bands in the input and output cubes ";
181 case InputOutputList:
185 string m =
"You have not specified any input or output cubes";
189 for (
unsigned int i = 0; i <
OutputCubes.size(); i++) {
191 string m =
"All output cubes must have the same number of lines ";
192 m +=
"as the first input cube or output cube";
197 if ( !(p_outputRequirements & Isis::SpatialMatch ) ) {
199 string m =
"All output cubes must have the same number of bands ";
200 m +=
"as the first input cube or output cube";
266 string m =
"The specified cube is out of range";
325 string m =
"The specified cube is out of range";
381 p_reverse = direction == BandsFirst ? true :
false;
394 return p_reverse ? BandsFirst : LinesFirst;
446 for (brick->begin(); !brick->end(); (*brick)++) {
486 for (brick->begin(); !brick->end(); (*brick)++) {
518 Brick *ibrick = NULL;
519 Brick *obrick = NULL;
530 for (
int i = 0; i < numBricks; i++) {
532 funct(*ibrick, *obrick);
558 Brick *ibrick = NULL;
559 Brick *obrick = NULL;
570 for (
int i = 0; i < numBricks; i++) {
572 funct(*ibrick, *obrick);
597 std::vector<Buffer *> &out)) {
600 vector<Brick *> imgrs;
601 vector<Buffer *> ibufs;
604 vector<Brick *> omgrs;
605 vector<Buffer *> obufs;
613 for(
int t = 0; t < numBricks; t++) {
615 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
623 for(
unsigned int i = 0; i <
OutputCubes.size(); i++) {
628 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
633 if(
Wraps() && imgrs[i]->end())
637 if(imgrs[i]->Band() != imgrs[0]->Band() &&
639 imgrs[i]->SetBaseBand(imgrs[0]->Band());
645 for(
unsigned int i = 0; i < ibufs.size(); i++) {
651 for(
unsigned int i = 0; i < obufs.size(); i++) {
672 std::vector<Buffer *> &out)> funct) {
675 vector<Brick *> imgrs;
676 vector<Buffer *> ibufs;
679 vector<Brick *> omgrs;
680 vector<Buffer *> obufs;
688 for(
int t = 0; t < numBricks; t++) {
690 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
698 for(
unsigned int i = 0; i <
OutputCubes.size(); i++) {
703 for(
unsigned int i = 0; i <
InputCubes.size(); i++) {
708 if(
Wraps() && imgrs[i]->end())
712 if(imgrs[i]->Band() != imgrs[0]->Band() &&
714 imgrs[i]->SetBaseBand(imgrs[0]->Band());
720 for(
unsigned int i = 0; i < ibufs.size(); i++) {
726 for(
unsigned int i = 0; i < obufs.size(); i++) {
762 int isisReportedProgress = 0;
763 int lastProgressValue = future.progressValue();
769 while (!future.isFinished()) {
770 sleeper.tryLock(100);
772 if (future.progressValue() != lastProgressValue) {
773 lastProgressValue = future.progressValue();
776 int isisProgressValue = lastProgressValue;
777 while (isisReportedProgress < isisProgressValue) {
779 isisReportedProgress++;
784 while (isisReportedProgress < future.progressValue()) {
786 isisReportedProgress++;
808 vector<Cube *> cubes)
const {
813 for (
unsigned int i = 0; i < cubes.size(); i++) {
814 int sampleCount = cubes[i]->sampleCount();
815 int lineCount = cubes[i]->lineCount();
816 int bandCount = cubes[i]->bandCount();
818 if (sampleCount > maxSamples)
819 maxSamples = sampleCount;
820 if (lineCount > maxLines)
821 maxLines = lineCount;
822 if (bandCount > maxBands)
823 maxBands = bandCount;
826 vector<int> maxDimensions;
827 maxDimensions.push_back(maxSamples);
828 maxDimensions.push_back(maxLines);
829 maxDimensions.push_back(maxBands);
830 return maxDimensions;
852 string m =
"You can only specify exactly one input or output cube";
862 string m =
"Use the SetBrickSize() or SetInputBrickSize() method to set"
863 " the input brick size";
881 string m =
"Use the SetBrickSize() or SetOutputBrickSize() method to "
882 "set the output brick size";
919 string m =
"You must specify exactly one input cube";
923 string m =
"You must specify exactly one output cube";
926 SetBricks(InputOutput);
929 string m =
"Use the SetBrickSize(), SetInputBrickSize(), or "
930 "SetOutputBrickSize() method to set the brick sizes";
958 vector<Cube *> allCubes;
962 int maxSamples = maxDimensions[0];
963 int maxLines = maxDimensions[1];
964 int maxBands = maxDimensions[2];
966 *ibrick =
new Brick(maxSamples, maxLines, maxBands,
972 *obrick =
new Brick(maxSamples, maxLines, maxBands,
981 if((*ibrick)->Bricks() > (*obrick)->Bricks()) {
982 numBricks = (*ibrick)->Bricks();
985 numBricks = (*obrick)->Bricks();
1009 vector<Buffer *> & obufs,
1010 vector<Brick *> & imgrs,
1011 vector<Brick *> & omgrs) {
1014 string m =
"You have not specified any input or output cubes";
1018 SetBricks(InputOutputList);
1022 string m =
"Use the SetBrickSize() or SetInputBrick() method to set the "
1023 "input brick size(s)";
1031 string m =
"Use the SetBrickSize() or SetOutputBrick() method to set the "
1032 "output brick size(s)";
1053 for (
unsigned int i = 0; i <
OutputCubes.size(); i++)
1056 maxSamples = maxDimensions[0];
1057 maxLines = maxDimensions[1];
1058 maxBands = maxDimensions[2];
1061 for (
unsigned int i = 1; i <=
InputCubes.size(); i++) {
1062 Brick *ibrick = NULL;
1074 ibrick =
new Brick(maxSamples, maxLines, maxBands,
1082 ibufs.push_back(ibrick);
1083 imgrs.push_back(ibrick);
1084 if(numBricks < ibrick->Bricks()) {
1085 numBricks = ibrick->Bricks();
1089 for (
unsigned int i = 1; i <=
OutputCubes.size(); i++) {
1090 Brick *obrick = NULL;
1099 obrick =
new Brick(maxSamples, maxLines, maxBands,
1107 obufs.push_back(obrick);
1108 omgrs.push_back(obrick);
1109 if(numBricks < obrick->Bricks()) {
1110 numBricks = obrick->Bricks();
1124 m_currentPosition(position) {
1135 m_currentPosition(other.m_currentPosition) {
1143 m_currentPosition = -1;
1153 m_currentPosition++;
Buffer for containing a three dimensional section of an image.
Buffer for reading and writing cube data.
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes.
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
@ Programmer
This error is for when a programmer made an API call that was illegal.
This class is designed to iterate over all brick positions in a cube.
ProcessIterator(int position)
Initialize a process iterator given a position.
virtual ~ProcessIterator()
Destructor.
ProcessIterator & operator++()
Increment the process iterator to the next position.
bool p_wrapOption
Indicates whether the brick manager will wrap.
std::vector< int > p_inputBrickBands
Number of bands in the input bricks.
void SetProcessingDirection(ProcessingDirection direction)
Set the direction the data will be read, either all lines in a single band proceeding to the next ban...
std::vector< int > p_outputBrickLines
Number of lines in the output bricks.
bool p_inputBrickSizeSet
Indicates whether the brick size has been set.
void Finalize()
Cleans up by closing cubes and freeing memory.
bool PrepProcessCubeInPlace(Cube **cube, Brick **bricks)
Prepare and check to run "function" parameter for StartProcess(void funct(Buffer &in)) and StartProce...
bool p_reverse
Use the reverse option for constructing the Buffer objects when the Processing Direction is changed f...
ProcessByBrick()
Constructs a ProcessByBrick object.
void SetOutputBrickSize(int ns, int nl, int nb)
Sets the size of all output bricks.
int PrepProcessCube(Brick **ibrick, Brick **obrick)
Prepare and check to run "function" parameter for StartProcess(void funct(Buffer &in,...
void VerifyCubes(IOCubes cn)
Verifies the dimensions of the input/output cubes.
void SetInputBrickSize(int ns, int nl, int nb)
Sets the size of all input bricks.
std::vector< int > p_inputBrickSamples
Number of samples in the input bricks.
virtual void StartProcess(void funct(Buffer &in))
Starts the systematic processing of the input cube by moving an arbitrarily-shaped brick through the ...
Cube * SetInputCube(const QString ¶meter, int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
std::vector< int > p_outputBrickBands
Number of bands in the output bricks.
void SetBrickSize(int ns, int nl, int nb)
Sets the input and output bricks sizes to the given number of samples, lines, and bands.
void SetWrap(bool wrap)
This wrapping option only applys when there are two or more input cubes.
bool Wraps()
Returns true if the wrapping option is enabled.
virtual ~ProcessByBrick()
Destroys the ProcessByBrick object.
void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
virtual Cube * SetOutputCube(const QString &fname, const CubeAttributeOutput &att)
Create the output file.
std::vector< int > p_inputBrickLines
Number of lines in the input bricks.
ProcessingDirection GetProcessingDirection()
Returns the direction the data will be read, either all lines in a single band proceeding to the next...
int PrepProcessCubes(std::vector< Buffer * > &ibufs, std::vector< Buffer * > &obufs, std::vector< Brick * > &imgrs, std::vector< Brick * > &omgrs)
Prepare and check to run "function" parameter for StartProcess(void funct(vector<Buffer *> &in,...
void BlockingReportProgress(QFuture< void > &future)
This method blocks until the future reports that it is finished.
bool p_outputBrickSizeSet
Indicates whether the brick size has been set.
std::vector< int > p_outputBrickSamples
Number of samples in the output bricks.
std::vector< int > CalculateMaxDimensions(std::vector< Cube * > cubes) const
Calculates the maximum dimensions of all the cubes and returns them in a vector where position 0 is t...
virtual void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Isis::Progress * p_progress
Pointer to a Progress object.
virtual Isis::Cube * SetOutputCube(const QString ¶meter)
Allocates a user-specified output cube whose size matches the first input cube.
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
void CheckStatus()
Checks and updates the status.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.