Loading isis/src/base/apps/desmile/desmile.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ void IsisMain() { ProcessBySpectra procSpectra; procSpectra.SetOutputRequirements(Isis::SpatialMatch); Cube *inCube = procSpectra.SetInputCube("FROM"); // Get the spectral information for the input cube Loading isis/src/base/objs/ProcessByBrick/ProcessByBrick.cpp +135 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ namespace Isis { p_outputBrickLines.clear(); p_outputBrickBands.clear(); p_outputRequirements = 0; p_inputBrickSizeSet = false; p_outputBrickSizeSet = false; p_wrapOption = false; Loading @@ -44,6 +45,8 @@ namespace Isis { } ProcessByBrick::~ProcessByBrick() { } Loading Loading @@ -104,6 +107,136 @@ namespace Isis { } void ProcessByBrick::SetOutputRequirements(int outputRequirements) { p_outputRequirements = outputRequirements; } void ProcessByBrick::SetBricks(IOCubes cn){ ; } /** * Verifies the dimensions of the input/output cubes. * * @param cn An IOCubes enumeration for one of three possible Input/Output * situations: * InPlace: The input cube is the output cube * InputOutput: One input cube and one output cube * InputOutputList: A vector of input and output cubes. The input vector * is not necessarily the same length as the output vector * * @throws iException::Message */ void ProcessByBrick::VerifyCubes(IOCubes cn){ switch(cn){ //Error check case InPlace: if (InputCubes.size() +OutputCubes.size() > 1) { string m = "You can only specify exactly one input or output cube"; throw IException(IException::Programmer,m,_FILEINFO_); } else if ( (InputCubes.size() + OutputCubes.size() == 0) ){ string m = "You haven't specified an input or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } break; case InputOutput: //Error checks ... there must be one input and output if(InputCubes.size() != 1) { string m = "You must specify exactly one input cube"; throw IException(IException::Programmer, m, _FILEINFO_); } else if(OutputCubes.size() != 1) { string m = "You must specify exactly one output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } // The lines in the input and output must match if(InputCubes[0]->lineCount() != OutputCubes[0]->lineCount()) { string m = "The number of lines in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } if(InputCubes[0]->sampleCount() != OutputCubes[0]->sampleCount()) { string m = "The number of samples in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } // The bands in the input and output must match //If we are only looking for a spatial match (just match lines/samples) //but not bands, then we skip over this check. if ( !(p_outputRequirements & Isis::SpatialMatch ) ) { if(InputCubes[0]->bandCount() != OutputCubes[0]->bandCount()) { string m = "The number of bands in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } } break; case InputOutputList: // Make sure we had an image if (InputCubes.size() + OutputCubes.size() < 1) { string m = "You have not specified any input or output cubes"; throw IException(IException::Programmer, m, _FILEINFO_); } for (unsigned int i = 0; i < OutputCubes.size(); i++) { if (OutputCubes[i]->lineCount() != OutputCubes[0]->lineCount() ) { string m = "All output cubes must have the same number of lines "; m += "as the first input cube or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } //If we are only looking for a spatial match (just match lines/samples) //but not bands, then we skip over this check. if ( !(p_outputRequirements & Isis::SpatialMatch ) ) { if (OutputCubes[i]->bandCount() != OutputCubes[0]->bandCount() ) { string m = "All output cubes must have the same number of bands "; m += "as the first input cube or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } } } break; }//end switch } /** * Sets the input and output bricks sizes to the given number of samples, * lines, and bands. Loading @@ -114,6 +247,8 @@ namespace Isis { * * @param nb Number of bands */ void ProcessByBrick::SetBrickSize(int ns, int nl, int nb) { SetInputBrickSize(ns, nl, nb); SetOutputBrickSize(ns, nl, nb); Loading isis/src/base/objs/ProcessByBrick/ProcessByBrick.h +16 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,10 @@ namespace Isis { //! Destroys the ProcessByBrick object virtual ~ProcessByBrick(); enum IOCubes{InPlace, InputOutput, InputOutputList}; enum ProcessingDirection { LinesFirst, BandsFirst Loading @@ -111,6 +115,9 @@ namespace Isis { const CubeAttributeInput &att, int requirements = 0); virtual void SetBricks(IOCubes cn); void VerifyCubes(IOCubes cn); void SetBrickSize(int ns, int nl, int nb); void SetInputBrickSize(int ns, int nl, int nb); Loading @@ -130,6 +137,7 @@ namespace Isis { void SetProcessingDirection(ProcessingDirection direction); ProcessingDirection GetProcessingDirection(); void SetOutputRequirements(int outputRequirements); void SetWrap(bool wrap); bool Wraps(); Loading Loading @@ -820,6 +828,10 @@ namespace Isis { set*/ bool p_outputBrickSizeSet; /**< Indicates whether the brick size has been set*/ int p_outputRequirements; std::vector<int> p_inputBrickSamples; /**< Number of samples in the input bricks*/ std::vector<int> p_inputBrickLines; /**< Number of lines in the input Loading @@ -832,6 +844,10 @@ namespace Isis { bricks*/ std::vector<int> p_outputBrickBands; /**< Number of bands in the output bricks*/ }; }; Loading isis/src/base/objs/ProcessByBrick/ProcessByBrick.truth +864 −9 File changed.Preview size limit exceeded, changes collapsed. Show changes isis/src/base/objs/ProcessByBrick/unitTest.cpp +219 −4 Original line number Diff line number Diff line Loading @@ -44,30 +44,232 @@ class Functor5 { void IsisMain() { Preference::Preferences(true); Cube *icube; ProcessByBrick p; cout << "Testing Functors\n"; { cout << "Functor2 - ProcessCube One Thread\n"; Cube *icube = p.SetInputCube("FROM"); //No cubes entered...will fail try{ p.VerifyCubes(ProcessByBrick::InPlace); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "1:" + exMsg.toStdString() << endl; } //InputCubes.size() !=1, will fail try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "2:" + exMsg.toStdString() << endl; } icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); //Input cube set, but output cube unset. Will fail try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "3:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount()+10, icube->lineCount(), icube->bandCount()); //Samples don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "4:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount()+10, icube->bandCount()); //Lines don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "5:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); //Bands don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "6:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.VerifyCubes(ProcessByBrick::InputOutput); //Everything is correct icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); try{ p.VerifyCubes(ProcessByBrick::InPlace); //Will fail } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "7:" + exMsg.toStdString() << endl; } p.EndProcess(); Functor2 functor; icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.ProcessCube(functor, false); p.EndProcess(); cout << "\n"; } { cout << "Functor3 - ProcessCubes One Thread\n"; // No input cubes specified, will fail try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "8:" + exMsg.toStdString() << endl; } p.EndProcess(); Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount()+10, icube->bandCount()); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); } { //Output[0] cube does not have the same number of lines as input[0] cube try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "9:" + exMsg.toStdString() << endl; } p.EndProcess(); } { Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); //Output[0] cube does not have the same number of bands as input[0] cube try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "10:" + exMsg.toStdString() << endl; } p.EndProcess(); } { Functor3 functor; Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.ProcessCubes(functor, false); p.EndProcess(); cout << "\n"; Loading @@ -80,7 +282,7 @@ void IsisMain() { p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); Functor4 functor; p.ProcessCube(functor); p.ProcessCube(functor,false); p.EndProcess(); Cube cube; cube.open(Application::GetUserInterface().GetFileName("TO")); Loading @@ -98,7 +300,20 @@ void IsisMain() { p.SetBrickSize(10, 10, 2); p.SetInputCube(cube); Functor5 functor; p.ProcessCubeInPlace(functor); try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString msg = ex.toString(); cout << msg.toStdString() << endl; } p.VerifyCubes(ProcessByBrick::InPlace); p.ProcessCubeInPlace(functor,false); p.EndProcess(); cube->close(); cube = new Cube; Loading Loading
isis/src/base/apps/desmile/desmile.cpp +3 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ void IsisMain() { ProcessBySpectra procSpectra; procSpectra.SetOutputRequirements(Isis::SpatialMatch); Cube *inCube = procSpectra.SetInputCube("FROM"); // Get the spectral information for the input cube Loading
isis/src/base/objs/ProcessByBrick/ProcessByBrick.cpp +135 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ namespace Isis { p_outputBrickLines.clear(); p_outputBrickBands.clear(); p_outputRequirements = 0; p_inputBrickSizeSet = false; p_outputBrickSizeSet = false; p_wrapOption = false; Loading @@ -44,6 +45,8 @@ namespace Isis { } ProcessByBrick::~ProcessByBrick() { } Loading Loading @@ -104,6 +107,136 @@ namespace Isis { } void ProcessByBrick::SetOutputRequirements(int outputRequirements) { p_outputRequirements = outputRequirements; } void ProcessByBrick::SetBricks(IOCubes cn){ ; } /** * Verifies the dimensions of the input/output cubes. * * @param cn An IOCubes enumeration for one of three possible Input/Output * situations: * InPlace: The input cube is the output cube * InputOutput: One input cube and one output cube * InputOutputList: A vector of input and output cubes. The input vector * is not necessarily the same length as the output vector * * @throws iException::Message */ void ProcessByBrick::VerifyCubes(IOCubes cn){ switch(cn){ //Error check case InPlace: if (InputCubes.size() +OutputCubes.size() > 1) { string m = "You can only specify exactly one input or output cube"; throw IException(IException::Programmer,m,_FILEINFO_); } else if ( (InputCubes.size() + OutputCubes.size() == 0) ){ string m = "You haven't specified an input or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } break; case InputOutput: //Error checks ... there must be one input and output if(InputCubes.size() != 1) { string m = "You must specify exactly one input cube"; throw IException(IException::Programmer, m, _FILEINFO_); } else if(OutputCubes.size() != 1) { string m = "You must specify exactly one output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } // The lines in the input and output must match if(InputCubes[0]->lineCount() != OutputCubes[0]->lineCount()) { string m = "The number of lines in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } if(InputCubes[0]->sampleCount() != OutputCubes[0]->sampleCount()) { string m = "The number of samples in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } // The bands in the input and output must match //If we are only looking for a spatial match (just match lines/samples) //but not bands, then we skip over this check. if ( !(p_outputRequirements & Isis::SpatialMatch ) ) { if(InputCubes[0]->bandCount() != OutputCubes[0]->bandCount()) { string m = "The number of bands in the input and output cubes "; m += "must match"; throw IException(IException::Programmer, m, _FILEINFO_); } } break; case InputOutputList: // Make sure we had an image if (InputCubes.size() + OutputCubes.size() < 1) { string m = "You have not specified any input or output cubes"; throw IException(IException::Programmer, m, _FILEINFO_); } for (unsigned int i = 0; i < OutputCubes.size(); i++) { if (OutputCubes[i]->lineCount() != OutputCubes[0]->lineCount() ) { string m = "All output cubes must have the same number of lines "; m += "as the first input cube or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } //If we are only looking for a spatial match (just match lines/samples) //but not bands, then we skip over this check. if ( !(p_outputRequirements & Isis::SpatialMatch ) ) { if (OutputCubes[i]->bandCount() != OutputCubes[0]->bandCount() ) { string m = "All output cubes must have the same number of bands "; m += "as the first input cube or output cube"; throw IException(IException::Programmer, m, _FILEINFO_); } } } break; }//end switch } /** * Sets the input and output bricks sizes to the given number of samples, * lines, and bands. Loading @@ -114,6 +247,8 @@ namespace Isis { * * @param nb Number of bands */ void ProcessByBrick::SetBrickSize(int ns, int nl, int nb) { SetInputBrickSize(ns, nl, nb); SetOutputBrickSize(ns, nl, nb); Loading
isis/src/base/objs/ProcessByBrick/ProcessByBrick.h +16 −0 Original line number Diff line number Diff line Loading @@ -98,6 +98,10 @@ namespace Isis { //! Destroys the ProcessByBrick object virtual ~ProcessByBrick(); enum IOCubes{InPlace, InputOutput, InputOutputList}; enum ProcessingDirection { LinesFirst, BandsFirst Loading @@ -111,6 +115,9 @@ namespace Isis { const CubeAttributeInput &att, int requirements = 0); virtual void SetBricks(IOCubes cn); void VerifyCubes(IOCubes cn); void SetBrickSize(int ns, int nl, int nb); void SetInputBrickSize(int ns, int nl, int nb); Loading @@ -130,6 +137,7 @@ namespace Isis { void SetProcessingDirection(ProcessingDirection direction); ProcessingDirection GetProcessingDirection(); void SetOutputRequirements(int outputRequirements); void SetWrap(bool wrap); bool Wraps(); Loading Loading @@ -820,6 +828,10 @@ namespace Isis { set*/ bool p_outputBrickSizeSet; /**< Indicates whether the brick size has been set*/ int p_outputRequirements; std::vector<int> p_inputBrickSamples; /**< Number of samples in the input bricks*/ std::vector<int> p_inputBrickLines; /**< Number of lines in the input Loading @@ -832,6 +844,10 @@ namespace Isis { bricks*/ std::vector<int> p_outputBrickBands; /**< Number of bands in the output bricks*/ }; }; Loading
isis/src/base/objs/ProcessByBrick/ProcessByBrick.truth +864 −9 File changed.Preview size limit exceeded, changes collapsed. Show changes
isis/src/base/objs/ProcessByBrick/unitTest.cpp +219 −4 Original line number Diff line number Diff line Loading @@ -44,30 +44,232 @@ class Functor5 { void IsisMain() { Preference::Preferences(true); Cube *icube; ProcessByBrick p; cout << "Testing Functors\n"; { cout << "Functor2 - ProcessCube One Thread\n"; Cube *icube = p.SetInputCube("FROM"); //No cubes entered...will fail try{ p.VerifyCubes(ProcessByBrick::InPlace); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "1:" + exMsg.toStdString() << endl; } //InputCubes.size() !=1, will fail try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "2:" + exMsg.toStdString() << endl; } icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); //Input cube set, but output cube unset. Will fail try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "3:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount()+10, icube->lineCount(), icube->bandCount()); //Samples don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "4:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount()+10, icube->bandCount()); //Lines don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "5:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); //Bands don't match try{ p.VerifyCubes(ProcessByBrick::InputOutput); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "6:" + exMsg.toStdString() << endl; } p.EndProcess(); icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.VerifyCubes(ProcessByBrick::InputOutput); //Everything is correct icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); try{ p.VerifyCubes(ProcessByBrick::InPlace); //Will fail } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "7:" + exMsg.toStdString() << endl; } p.EndProcess(); Functor2 functor; icube = p.SetInputCube("FROM"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.ProcessCube(functor, false); p.EndProcess(); cout << "\n"; } { cout << "Functor3 - ProcessCubes One Thread\n"; // No input cubes specified, will fail try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "8:" + exMsg.toStdString() << endl; } p.EndProcess(); Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount()+10, icube->bandCount()); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); } { //Output[0] cube does not have the same number of lines as input[0] cube try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "9:" + exMsg.toStdString() << endl; } p.EndProcess(); } { Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); //Output[0] cube does not have the same number of bands as input[0] cube try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString exMsg = ex.toString(); cout << "10:" + exMsg.toStdString() << endl; } p.EndProcess(); } { Functor3 functor; Cube *icube = p.SetInputCube("FROM"); p.SetInputCube("FROM2"); p.SetBrickSize(10, 10, 2); p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()+10); p.SetOutputCube("TO2", icube->sampleCount(), icube->lineCount(), icube->bandCount()); p.ProcessCubes(functor, false); p.EndProcess(); cout << "\n"; Loading @@ -80,7 +282,7 @@ void IsisMain() { p.SetOutputCube("TO", icube->sampleCount(), icube->lineCount(), icube->bandCount()); Functor4 functor; p.ProcessCube(functor); p.ProcessCube(functor,false); p.EndProcess(); Cube cube; cube.open(Application::GetUserInterface().GetFileName("TO")); Loading @@ -98,7 +300,20 @@ void IsisMain() { p.SetBrickSize(10, 10, 2); p.SetInputCube(cube); Functor5 functor; p.ProcessCubeInPlace(functor); try{ p.VerifyCubes(ProcessByBrick::InputOutputList); } catch(Isis::IException &ex){ QString msg = ex.toString(); cout << msg.toStdString() << endl; } p.VerifyCubes(ProcessByBrick::InPlace); p.ProcessCubeInPlace(functor,false); p.EndProcess(); cube->close(); cube = new Cube; Loading