Isis 3 Programmer Reference
ProcessByBrick.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include <functional>
8
9#include "ProcessByBrick.h"
10#include "Brick.h"
11#include "Cube.h"
12
13using namespace std;
14
15namespace Isis {
17 p_inputBrickSamples.clear();
18 p_inputBrickLines.clear();
19 p_inputBrickBands.clear();
20
22 p_outputBrickLines.clear();
23 p_outputBrickBands.clear();
24
25 p_outputRequirements = 0;
26 p_inputBrickSizeSet = false;
28 p_wrapOption = false;
29 p_reverse = false;
30 }
31
32
33
34
37
38
58 Cube *ProcessByBrick::SetInputCube(const QString &parameter,
59 int requirements) {
60 int allRequirements = AllMatchOrOne;
61 allRequirements |= requirements;
62 return Process::SetInputCube(parameter, allRequirements);
63 }
64
86 Cube *ProcessByBrick::SetInputCube(const QString &file,
87 const CubeAttributeInput &att,
88 int requirements) {
89 int allRequirements = AllMatchOrOne;
90 allRequirements |= requirements;
91 return Process::SetInputCube(file, att, allRequirements);
92 }
93
94
95void ProcessByBrick::SetOutputRequirements(int outputRequirements) {
96
97 p_outputRequirements = outputRequirements;
98
99
100}
101
102 void ProcessByBrick::SetBricks(IOCubes cn){
103
104 ;
105
106 }
107
121
122 switch(cn){
123
124 //Error check
125 case InPlace:
126
127 if (InputCubes.size() +OutputCubes.size() > 1) {
128 string m = "You can only specify exactly one input or output cube";
129 throw IException(IException::Programmer,m,_FILEINFO_);
130 }
131 else if ( (InputCubes.size() + OutputCubes.size() == 0) ){
132
133 string m = "You haven't specified an input or output cube";
134 throw IException(IException::Programmer, m, _FILEINFO_);
135 }
136
137 break;
138
139 case InputOutput:
140
141 //Error checks ... there must be one input and output
142 if(InputCubes.size() != 1) {
143 string m = "You must specify exactly one input cube";
144 throw IException(IException::Programmer, m, _FILEINFO_);
145 }
146 else if(OutputCubes.size() != 1) {
147 string m = "You must specify exactly one output cube";
148 throw IException(IException::Programmer, m, _FILEINFO_);
149 }
150
151 // The lines in the input and output must match
152 if(InputCubes[0]->lineCount() != OutputCubes[0]->lineCount()) {
153 string m = "The number of lines in the input and output cubes ";
154 m += "must match";
155 throw IException(IException::Programmer, m, _FILEINFO_);
156 }
157
158 if(InputCubes[0]->sampleCount() != OutputCubes[0]->sampleCount()) {
159 string m = "The number of samples in the input and output cubes ";
160 m += "must match";
161 throw IException(IException::Programmer, m, _FILEINFO_);
162 }
163
164
165 // The bands in the input and output must match
166
167 //If we are only looking for a spatial match (just match lines/samples)
168 //but not bands, then we skip over this check.
169
170 if ( !(p_outputRequirements & Isis::SpatialMatch ) ) {
171 if(InputCubes[0]->bandCount() != OutputCubes[0]->bandCount()) {
172 string m = "The number of bands in the input and output cubes ";
173 m += "must match";
174 throw IException(IException::Programmer, m, _FILEINFO_);
175 }
176
177 }
178
179 break;
180
181 case InputOutputList:
182
183 // Make sure we had an image
184 if (InputCubes.size() + OutputCubes.size() < 1) {
185 string m = "You have not specified any input or output cubes";
186 throw IException(IException::Programmer, m, _FILEINFO_);
187 }
188
189 for (unsigned int i = 0; i < OutputCubes.size(); i++) {
190 if (OutputCubes[i]->lineCount() != OutputCubes[0]->lineCount() ) {
191 string m = "All output cubes must have the same number of lines ";
192 m += "as the first input cube or output cube";
193 throw IException(IException::Programmer, m, _FILEINFO_);
194 }
195 //If we are only looking for a spatial match (just match lines/samples)
196 //but not bands, then we skip over this check.
197 if ( !(p_outputRequirements & Isis::SpatialMatch ) ) {
198 if (OutputCubes[i]->bandCount() != OutputCubes[0]->bandCount() ) {
199 string m = "All output cubes must have the same number of bands ";
200 m += "as the first input cube or output cube";
201 throw IException(IException::Programmer, m, _FILEINFO_);
202 }
203 }
204 }
205
206 break;
207
208
209 }//end switch
210
211 }
212
213
214
225 void ProcessByBrick::SetBrickSize(int ns, int nl, int nb) {
226 SetInputBrickSize(ns, nl, nb);
227 SetOutputBrickSize(ns, nl, nb);
228 return;
229 }
230
231
241 void ProcessByBrick::SetInputBrickSize(int ns, int nl, int nb) {
242 p_inputBrickSamples.clear();
243 p_inputBrickSamples.resize(InputCubes.size() + 1, ns);
244 p_inputBrickLines.clear();
245 p_inputBrickLines.resize(InputCubes.size() + 1, nl);
246 p_inputBrickBands.clear();
247 p_inputBrickBands.resize(InputCubes.size() + 1, nb);
248
249 p_inputBrickSizeSet = true;
250 }
251
252
264 void ProcessByBrick::SetInputBrickSize(int ns, int nl, int nb, int cube) {
265 if (cube > (int)InputCubes.size()) {
266 string m = "The specified cube is out of range";
267 throw IException(IException::Programmer, m, _FILEINFO_);
268 }
269
270 // If a default size has already been set, use it to fill in
271 if (p_inputBrickSamples.size() > 0) {
273 p_inputBrickLines.resize(InputCubes.size() + 1, p_inputBrickLines[0]);
274 p_inputBrickBands.resize(InputCubes.size() + 1, p_inputBrickBands[0]);
275 }
276 // otherwise, make this the default size
277 else {
278 p_inputBrickSamples.resize(InputCubes.size() + 1, ns);
279 p_inputBrickLines.resize(InputCubes.size() + 1, nl);
280 p_inputBrickBands.resize(InputCubes.size() + 1, nb);
281 }
282
283 p_inputBrickSamples[cube] = ns;
284 p_inputBrickLines[cube] = nl;
285 p_inputBrickBands[cube] = nb;
286
287 p_inputBrickSizeSet = true;
288 }
289
290
300 void ProcessByBrick::SetOutputBrickSize(int ns, int nl, int nb) {
301 p_outputBrickSamples.clear();
302 p_outputBrickSamples.resize(OutputCubes.size() + 1, ns);
303 p_outputBrickLines.clear();
304 p_outputBrickLines.resize(OutputCubes.size() + 1, nl);
305 p_outputBrickBands.clear();
306 p_outputBrickBands.resize(OutputCubes.size() + 1, nb);
307
309 }
310
311
323 void ProcessByBrick::SetOutputBrickSize(int ns, int nl, int nb, int cube) {
324 if(cube > (int)OutputCubes.size()) {
325 string m = "The specified cube is out of range";
326 throw IException(IException::Programmer, m, _FILEINFO_);
327 }
328
329 // If a default size has already been set, use it to fill in
330 if(p_outputBrickSamples.size() > 0) {
331 p_outputBrickSamples.resize(OutputCubes.size() + 1,
335 }
336 // otherwise, make this the default size
337 else {
338 p_outputBrickSamples.resize(OutputCubes.size() + 1, ns);
339 p_outputBrickLines.resize(OutputCubes.size() + 1, nl);
340 p_outputBrickBands.resize(OutputCubes.size() + 1, nb);
341 }
342
343 p_outputBrickSamples[cube] = ns;
344 p_outputBrickLines[cube] = nl;
345 p_outputBrickBands[cube] = nb;
346
348 }
349
365 const Isis::CubeAttributeOutput &att) {
366 int nl = InputCubes[0]->lineCount();
367 int ns = InputCubes[0]->sampleCount();
368 int nb = InputCubes[0]->bandCount();
369 return Process::SetOutputCube(fname, att, ns, nl, nb);
370 }
371
380 void ProcessByBrick::SetProcessingDirection(ProcessingDirection direction) {
381 p_reverse = direction == BandsFirst ? true : false;
382 }
383
384
393 ProcessByBrick::ProcessingDirection ProcessByBrick::GetProcessingDirection() {
394 return p_reverse ? BandsFirst : LinesFirst;
395 }
396
397
409 void ProcessByBrick::SetWrap(bool wrap) {
410 p_wrapOption = wrap;
411 }
412
413
420 return p_wrapOption;
421 }
422
423
436 void ProcessByBrick::StartProcess(void funct(Buffer &in)) {
437 Cube *cube = NULL;
438 Brick *brick = NULL;
439
440 bool haveInput = PrepProcessCubeInPlace(&cube, &brick);
441
442 // Loop and let the app programmer work with the bricks
443 p_progress->SetMaximumSteps(brick->Bricks());
445
446 for (brick->begin(); !brick->end(); (*brick)++) {
447 if (haveInput)
448 cube->read(*brick); // input only
449
450 funct(*brick);
451
452 // output only or input/output
453 if ((!haveInput) || (cube->isReadWrite())) {
454 cube->write(*brick);
455 }
456
458 }
459
460 delete brick;
461 }
462
463
476 void ProcessByBrick::StartProcess(std::function<void(Buffer &in)> funct ) {
477 Cube *cube = NULL;
478 Brick *brick = NULL;
479
480 bool haveInput = PrepProcessCubeInPlace(&cube, &brick);
481
482 // Loop and let the app programmer work with the bricks
483 p_progress->SetMaximumSteps(brick->Bricks());
485
486 for (brick->begin(); !brick->end(); (*brick)++) {
487 if (haveInput)
488 cube->read(*brick); // input only
489
490 funct(*brick);
491
492 // output only or input/output
493 if ((!haveInput) || (cube->isReadWrite())) {
494 cube->write(*brick);
495 }
496
498 }
499
500 delete brick;
501 }
502
503
517 void ProcessByBrick::StartProcess(void funct(Buffer &in, Buffer &out)) {
518 Brick *ibrick = NULL;
519 Brick *obrick = NULL;
520
521 int numBricks = PrepProcessCube(&ibrick, &obrick);
522
523 // Loop and let the app programmer work with the bricks
524 p_progress->SetMaximumSteps(numBricks);
526
527 ibrick->begin();
528 obrick->begin();
529
530 for (int i = 0; i < numBricks; i++) {
531 InputCubes[0]->read(*ibrick);
532 funct(*ibrick, *obrick);
533 OutputCubes[0]->write(*obrick);
535 (*ibrick)++;
536 (*obrick)++;
537 }
538
539 delete ibrick;
540 delete obrick;
541 }
542
543
557 void ProcessByBrick::StartProcess(std::function<void(Buffer &in, Buffer &out)> funct ) {
558 Brick *ibrick = NULL;
559 Brick *obrick = NULL;
560
561 int numBricks = PrepProcessCube(&ibrick, &obrick);
562
563 // Loop and let the app programmer work with the bricks
564 p_progress->SetMaximumSteps(numBricks);
566
567 ibrick->begin();
568 obrick->begin();
569
570 for (int i = 0; i < numBricks; i++) {
571 InputCubes[0]->read(*ibrick);
572 funct(*ibrick, *obrick);
573 OutputCubes[0]->write(*obrick);
575 (*ibrick)++;
576 (*obrick)++;
577 }
578
579 delete ibrick;
580 delete obrick;
581 }
582
583
596 void ProcessByBrick::StartProcess(void funct(std::vector<Buffer *> &in,
597 std::vector<Buffer *> &out)) {
598 // Construct two vectors of brick buffer managers
599 // The input buffer managers
600 vector<Brick *> imgrs;
601 vector<Buffer *> ibufs;
602
603 // And the output buffer managers
604 vector<Brick *> omgrs;
605 vector<Buffer *> obufs;
606
607 int numBricks = PrepProcessCubes(ibufs, obufs, imgrs, omgrs);
608
609 // Loop and let the app programmer process the bricks
610 p_progress->SetMaximumSteps(numBricks);
612
613 for(int t = 0; t < numBricks; t++) {
614 // Read the input buffers
615 for(unsigned int i = 0; i < InputCubes.size(); i++) {
616 InputCubes[i]->read(*ibufs[i]);
617 }
618
619 // Pass them to the application function
620 funct(ibufs, obufs);
621
622 // And copy them into the output cubes
623 for(unsigned int i = 0; i < OutputCubes.size(); i++) {
624 OutputCubes[i]->write(*obufs[i]);
625 omgrs[i]->next();
626 }
627
628 for(unsigned int i = 0; i < InputCubes.size(); i++) {
629 imgrs[i]->next();
630
631 // if the manager has reached the end and the
632 // wrap option is on, wrap around to the beginning
633 if(Wraps() && imgrs[i]->end())
634 imgrs[i]->begin();
635
636 // Enforce same band
637 if(imgrs[i]->Band() != imgrs[0]->Band() &&
638 InputCubes[i]->bandCount() != 1) {
639 imgrs[i]->SetBaseBand(imgrs[0]->Band());
640 }
641 }
643 }
644
645 for(unsigned int i = 0; i < ibufs.size(); i++) {
646 delete ibufs[i];
647 }
648 ibufs.clear();
649 imgrs.clear();
650
651 for(unsigned int i = 0; i < obufs.size(); i++) {
652 delete obufs[i];
653 }
654 obufs.clear();
655 omgrs.clear();
656 }
657
658
671 void ProcessByBrick::StartProcess(std::function<void(std::vector<Buffer *> &in,
672 std::vector<Buffer *> &out)> funct) {
673 // Construct two vectors of brick buffer managers
674 // The input buffer managers
675 vector<Brick *> imgrs;
676 vector<Buffer *> ibufs;
677
678 // And the output buffer managers
679 vector<Brick *> omgrs;
680 vector<Buffer *> obufs;
681
682 int numBricks = PrepProcessCubes(ibufs, obufs, imgrs, omgrs);
683
684 // Loop and let the app programmer process the bricks
685 p_progress->SetMaximumSteps(numBricks);
687
688 for(int t = 0; t < numBricks; t++) {
689 // Read the input buffers
690 for(unsigned int i = 0; i < InputCubes.size(); i++) {
691 InputCubes[i]->read(*ibufs[i]);
692 }
693
694 // Pass them to the application function
695 funct(ibufs, obufs);
696
697 // And copy them into the output cubes
698 for(unsigned int i = 0; i < OutputCubes.size(); i++) {
699 OutputCubes[i]->write(*obufs[i]);
700 omgrs[i]->next();
701 }
702
703 for(unsigned int i = 0; i < InputCubes.size(); i++) {
704 imgrs[i]->next();
705
706 // if the manager has reached the end and the
707 // wrap option is on, wrap around to the beginning
708 if(Wraps() && imgrs[i]->end())
709 imgrs[i]->begin();
710
711 // Enforce same band
712 if(imgrs[i]->Band() != imgrs[0]->Band() &&
713 InputCubes[i]->bandCount() != 1) {
714 imgrs[i]->SetBaseBand(imgrs[0]->Band());
715 }
716 }
718 }
719
720 for(unsigned int i = 0; i < ibufs.size(); i++) {
721 delete ibufs[i];
722 }
723 ibufs.clear();
724 imgrs.clear();
725
726 for(unsigned int i = 0; i < obufs.size(); i++) {
727 delete obufs[i];
728 }
729 obufs.clear();
730 omgrs.clear();
731 }
732
744
745
752
753
761 void ProcessByBrick::BlockingReportProgress(QFuture<void> &future) {
762 int isisReportedProgress = 0;
763 int lastProgressValue = future.progressValue();
764 // Using a mutex with a timeout isn't as bad of a hack as inheriting QThread
765 // but there ought to be a better way.
766 // Does having a local mutex make sense?
767 QMutex sleeper;
768 sleeper.lock();
769 while (!future.isFinished()) {
770 sleeper.tryLock(100);
771
772 if (future.progressValue() != lastProgressValue) {
773 lastProgressValue = future.progressValue();
774 // Progress min/max are reporting as 0's currently, so we're
775 // assuming the progress value is an Isis progress value.
776 int isisProgressValue = lastProgressValue;
777 while (isisReportedProgress < isisProgressValue) {
779 isisReportedProgress++;
780 }
781 }
782 }
783
784 while (isisReportedProgress < future.progressValue()) {
786 isisReportedProgress++;
787 }
788
789 // Need to unlock the mutex before it goes out of scope, otherwise Qt5 issues a warning
790 sleeper.unlock();
791 }
792
793
808 vector<Cube *> cubes) const {
809 int maxSamples = 0;
810 int maxLines = 0;
811 int maxBands = 0;
812
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();
817
818 if (sampleCount > maxSamples)
819 maxSamples = sampleCount;
820 if (lineCount > maxLines)
821 maxLines = lineCount;
822 if (bandCount > maxBands)
823 maxBands = bandCount;
824 }
825
826 vector<int> maxDimensions;
827 maxDimensions.push_back(maxSamples);
828 maxDimensions.push_back(maxLines);
829 maxDimensions.push_back(maxBands);
830 return maxDimensions;
831 }
832
833
850 // Error checks
851 if ((InputCubes.size() + OutputCubes.size()) != 1) {
852 string m = "You can only specify exactly one input or output cube";
853 throw IException(IException::Programmer, m, _FILEINFO_);
854 }
855
856 bool haveInput;
857 if (InputCubes.size() == 1) {
858
859 SetBricks(InPlace);
860 // Make sure the brick size has been set
861 if (!p_inputBrickSizeSet) {
862 string m = "Use the SetBrickSize() or SetInputBrickSize() method to set"
863 " the input brick size";
864 throw IException(IException::Programmer, m, _FILEINFO_);
865 }
866 // And the size is stored
867 else if (p_inputBrickSamples.size() == 1) {
869 p_inputBrickBands[0], 1);
870 }
871
872 haveInput = true;
873 *cube = InputCubes[0];
874 *bricks = new Brick(**cube, p_inputBrickSamples[1],
876 }
877 else {
878 SetBricks(InPlace);
879 // Make sure the brick size has been set
881 string m = "Use the SetBrickSize() or SetOutputBrickSize() method to "
882 "set the output brick size";
883 throw IException(IException::Programmer, m, _FILEINFO_);
884 }
885 // And the size is stored
886 else if (p_outputBrickSamples.size() == 1) {
888 p_outputBrickBands[0], 1);
889 }
890
891 haveInput = false;
892 *cube = OutputCubes[0];
893 *bricks = new Brick(**cube, p_outputBrickSamples[1],
895 }
896
897 return haveInput;
898 }
899
900
917 // Error checks ... there must be one input and output
918 if (InputCubes.size() != 1) {
919 string m = "You must specify exactly one input cube";
920 throw IException(IException::Programmer, m, _FILEINFO_);
921 }
922 else if (OutputCubes.size() != 1) {
923 string m = "You must specify exactly one output cube";
924 throw IException(IException::Programmer, m, _FILEINFO_);
925 }
926 SetBricks(InputOutput);
927 // Make sure the brick size has been set
929 string m = "Use the SetBrickSize(), SetInputBrickSize(), or "
930 "SetOutputBrickSize() method to set the brick sizes";
931 throw IException(IException::Programmer, m, _FILEINFO_);
932 }
933
934 // Make all input and/or output cubes have the same size
935 if (p_outputBrickSamples.size() == 1) {
937 p_outputBrickBands[0], 1);
938 }
939 if (p_inputBrickSamples.size() == 1) {
941 p_inputBrickBands[0], 1);
942 }
943
944 // Construct brick buffers
945 if (Wraps()) {
946 // Use the size of each cube as the area for the bricks to traverse since
947 // we will be wrapping if we hit the end of one, but not the other.
948 *ibrick = new Brick(*InputCubes[0], p_inputBrickSamples[1],
950 *obrick = new Brick(*OutputCubes[0], p_outputBrickSamples[1],
952 }
953 else {
954 // Since we are not wrapping, we need to find the maximum size of the
955 // input cube and the output cube. We will use this size when
956 // constructing each of the bricks' area to traverse so that we don't
957 // read into nonexistent bands of the smaller of the two cubes.
958 vector<Cube *> allCubes;
959 allCubes.push_back(InputCubes[0]);
960 allCubes.push_back(OutputCubes[0]);
961 vector<int> maxDimensions = CalculateMaxDimensions(allCubes);
962 int maxSamples = maxDimensions[0];
963 int maxLines = maxDimensions[1];
964 int maxBands = maxDimensions[2];
965
966 *ibrick = new Brick(maxSamples, maxLines, maxBands,
970 InputCubes[0]->pixelType(),
971 p_reverse);
972 *obrick = new Brick(maxSamples, maxLines, maxBands,
976 OutputCubes[0]->pixelType(),
977 p_reverse);
978 }
979
980 int numBricks;
981 if((*ibrick)->Bricks() > (*obrick)->Bricks()) {
982 numBricks = (*ibrick)->Bricks();
983 }
984 else {
985 numBricks = (*obrick)->Bricks();
986 }
987
988 return numBricks;
989 }
990
991
1008 int ProcessByBrick::PrepProcessCubes(vector<Buffer *> & ibufs,
1009 vector<Buffer *> & obufs,
1010 vector<Brick *> & imgrs,
1011 vector<Brick *> & omgrs) {
1012 // Make sure we had an image
1013 if(InputCubes.size() == 0 && OutputCubes.size() == 0) {
1014 string m = "You have not specified any input or output cubes";
1015 throw IException(IException::Programmer, m, _FILEINFO_);
1016 }
1017
1018 SetBricks(InputOutputList);
1019
1020 // Make sure the brick size has been set
1021 if(!p_inputBrickSizeSet && InputCubes.size() > 0) {
1022 string m = "Use the SetBrickSize() or SetInputBrick() method to set the "
1023 "input brick size(s)";
1024 throw IException(IException::Programmer, m, _FILEINFO_);
1025 }
1026 else if(p_inputBrickSizeSet && p_inputBrickSamples.size() == 1) {
1028 p_inputBrickBands[0], InputCubes.size());
1029 }
1030 if(!p_outputBrickSizeSet && OutputCubes.size() > 0) {
1031 string m = "Use the SetBrickSize() or SetOutputBrick() method to set the "
1032 "output brick size(s)";
1033 throw IException(IException::Programmer, m, _FILEINFO_);
1034 }
1035 else if(p_outputBrickSizeSet && p_outputBrickSamples.size() == 1) {
1037 p_outputBrickBands[0], OutputCubes.size());
1038 }
1039
1040 // this parameter holds the number of bricks to be used in processing
1041 // which is the maximum number of bricks of all the cubes.
1042 int numBricks = 0;
1043
1044 // If we are not wrapping, we need to find the maximum size of the input and
1045 // output cubes. We will use this size when constructing each of the bricks'
1046 // area to traverse so that we don't read into nonexistent bands of the
1047 // smaller cubes.
1048 int maxSamples = 0;
1049 int maxLines = 0;
1050 int maxBands = 0;
1051 if (!Wraps()) {
1052 vector<Cube *> allCubes(InputCubes);
1053 for (unsigned int i = 0; i < OutputCubes.size(); i++)
1054 allCubes.push_back(OutputCubes[i]);
1055 vector<int> maxDimensions = CalculateMaxDimensions(allCubes);
1056 maxSamples = maxDimensions[0];
1057 maxLines = maxDimensions[1];
1058 maxBands = maxDimensions[2];
1059 }
1060
1061 for (unsigned int i = 1; i <= InputCubes.size(); i++) {
1062 Brick *ibrick = NULL;
1063 if (Wraps()) {
1064 // Use the size of each cube as the area for the bricks to traverse
1065 // since we will be wrapping if we hit the end of a cube before we are
1066 // done processing.
1067 ibrick = new Brick(*InputCubes[i-1],
1071 p_reverse);
1072 }
1073 else {
1074 ibrick = new Brick(maxSamples, maxLines, maxBands,
1078 InputCubes[i - 1]->pixelType(),
1079 p_reverse);
1080 }
1081 ibrick->begin();
1082 ibufs.push_back(ibrick);
1083 imgrs.push_back(ibrick);
1084 if(numBricks < ibrick->Bricks()) {
1085 numBricks = ibrick->Bricks();
1086 }
1087 }
1088
1089 for (unsigned int i = 1; i <= OutputCubes.size(); i++) {
1090 Brick *obrick = NULL;
1091 if (Wraps()) {
1092 obrick = new Brick(*OutputCubes[i-1],
1096 p_reverse);
1097 }
1098 else {
1099 obrick = new Brick(maxSamples, maxLines, maxBands,
1103 OutputCubes[i - 1]->pixelType(),
1104 p_reverse);
1105 }
1106 obrick->begin();
1107 obufs.push_back(obrick);
1108 omgrs.push_back(obrick);
1109 if(numBricks < obrick->Bricks()) {
1110 numBricks = obrick->Bricks();
1111 }
1112 }
1113
1114 return numBricks;
1115 }
1116
1117
1124 m_currentPosition(position) {
1125 }
1126
1127
1134 const ProcessIterator &other) :
1135 m_currentPosition(other.m_currentPosition) {
1136 }
1137
1138
1143 m_currentPosition = -1;
1144 }
1145
1146
1153 m_currentPosition++;
1154 return *this;
1155 }
1156} // end namespace isis
Buffer for containing a three dimensional section of an image.
Definition Brick.h:45
Buffer for reading and writing cube data.
Definition Buffer.h:53
Manipulate and parse attributes of input cube filenames.
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes.
Definition Cube.h:168
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition Cube.cpp:813
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
Definition Cube.cpp:977
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
Definition Cube.cpp:230
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
This class is designed to iterate over all brick positions in a cube.
ProcessIterator(int position)
Initialize a process iterator given a position.
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 &parameter, 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.
Definition Process.cpp:462
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
Definition Process.h:185
Isis::Progress * p_progress
Pointer to a Progress object.
Definition Process.h:145
virtual Isis::Cube * SetOutputCube(const QString &parameter)
Allocates a user-specified output cube whose size matches the first input cube.
Definition Process.cpp:163
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
Definition Process.h:191
virtual Isis::Cube * SetInputCube(const QString &parameter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
Definition Process.cpp:139
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
Definition Progress.cpp:85
void CheckStatus()
Checks and updates the status.
Definition Progress.cpp:105
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.