Unverified Commit c4838a3a authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

added camdev tests (#4208)

* added camdev tests

* tempdir change

* prints
parent 5356b7c4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
#===============================================================================
set(CORE_LIST base database control qisis system socet)
set(CORE_LIST base database control qisis system socet dev)

get_subdirectory_list(${CMAKE_CURRENT_LIST_DIR} modules)

+111 −0
Original line number Diff line number Diff line
@@ -190,6 +190,117 @@ namespace Isis {
    return cube;
  }


  /**
   * Opens an input cube specified by the programmer and verifies requirements
   * are met.
   *
   * @param cube Programmer specified work file. For example
   *
   * @param att  The cube attributes to use when opening the input cube.
   *
   * @param requirements  Same as requirements on SetInputCube. See that method
   *                      for more details. Defaults to 0
   *
   *
   * @throws Isis::iException::Message
   */
  void Process::SetInputCube(Cube *cube, 
                                    int requirements) {
    // Test for same size or one in all dimensions
    if(requirements & Isis::AllMatchOrOne) {
      if(InputCubes.size() > 0) {
        if(cube->lineCount() != 1) {
          if(cube->lineCount() != InputCubes[0]->lineCount()) {
            QString message = "The number of lines in the secondary input cubes must match";
            message += " the primary input cube or be exactly one";
            throw IException(IException::User, message, _FILEINFO_);
          }
        }

        if(cube->sampleCount() != 1) {
          if(cube->sampleCount() != InputCubes[0]->sampleCount()) {
            QString message = "The number of samples in the secondary input cubes must match";
            message += " the primary input cube or be exactly one";
            throw IException(IException::User, message, _FILEINFO_);
          }
        }
        if(cube->bandCount() != 1) {
          if(cube->bandCount() != InputCubes[0]->bandCount()) {
            QString message = "The number of bands in the secondary input cubes must match";
            message += " the primary input cube or be exactly one";
            throw IException(IException::User, message, _FILEINFO_);
          }
        }

        // Do not do a spatial match if this flag was set
        requirements = requirements & !Isis::SpatialMatch;
      }
    }

    // Test for size match if requested
    if(requirements & Isis::SizeMatch) {
      if(InputCubes.size() > 0) {
        if(cube->lineCount() != InputCubes[0]->lineCount()) {
          QString message = "The number of lines in the input cubes must match";
          throw IException(IException::User, message, _FILEINFO_);
        }
        if(cube->sampleCount() != InputCubes[0]->sampleCount()) {
          QString message = "The number of samples in the input cubes must match";
          throw IException(IException::User, message, _FILEINFO_);
        }
        if(cube->bandCount() != InputCubes[0]->bandCount()) {
          QString message = "The number of bands in the input cubes must match";
          throw IException(IException::User, message, _FILEINFO_);
        }
      }
    }

    // Test for spatial match if requested
    if(requirements & Isis::SpatialMatch) {
      if(InputCubes.size() > 0) {
        if(cube->lineCount() != InputCubes[0]->lineCount()) {
          QString message = "The number of lines in the input cubes must match";
          throw IException(IException::User, message, _FILEINFO_);
        }
        if(cube->sampleCount() != InputCubes[0]->sampleCount()) {
          QString message = "The number of samples in the input cubes must match";
          throw IException(IException::User, message, _FILEINFO_);
        }
      }
    }

    // Test for one band
    if(requirements & Isis::OneBand) {
      if(cube->bandCount() != 1) {
        QString message = "Input cube [" + cube->fileName() + "] must have one band";
        throw IException(IException::User, message, _FILEINFO_);
      }
    }

    // Test for same bands or one band
    if(requirements & Isis::BandMatchOrOne) {
      if(cube->bandCount() != 1) {
        if(InputCubes.size() > 0) {
          if(cube->bandCount() != InputCubes[0]->bandCount()) {
            QString message = "The number of bands in the secondary input cubes must match";
            message += " the primary input cube or be exactly one";
            throw IException(IException::User, message, _FILEINFO_);
          }
        }
      }
    }

    if(cube != NULL && cube->isOpen()) {
      AddInputCube(cube, false);
    }
    else {
      QString message = "Input cube does not exist";
      throw IException(IException::User, message, _FILEINFO_);
    }
  }


  /**
   * Set the InputCube vector to an opened Cube which was dynamically allocated.
   * This is used if there already exists a valid opened cube
+2 −1
Original line number Diff line number Diff line
@@ -238,7 +238,8 @@ namespace Isis {
                               const Isis::CubeAttributeInput &att,
                               int requirements = 0);
      virtual void SetInputCube(Isis::Cube *inCube);

      virtual void SetInputCube(Cube *cube, 
                                    int requirements);

      virtual Isis::Cube *SetOutputCube(const QString &parameter);
      virtual Isis::Cube *SetOutputCubeStretch(const QString &parameter, UserInterface *ui=nullptr);
+758 −0

File added.

Preview size limit exceeded, changes collapsed.

+12 −0
Original line number Diff line number Diff line
#ifndef camdev_h 
#define camdev_h

#include "UserInterface.h"
#include "Cube.h"

namespace Isis {
  extern void camdev(Cube *icube, UserInterface &ui);
  extern void camdev(UserInterface &ui);
}

#endif
 No newline at end of file
Loading