Project

General

Profile

Bug #4698

ProcessByBrick is throwing an exception if brick sizes have not been set

Added by Tyler Wilson 9 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Impact:
Software Version:
Test Reviewer:
Story points:
1

Description

This should not be happening because the SetBricks() function is virtual and the brick sizes
are set in the children of ProcessByBrick. There are two boolean variables: p_outputBrickSizeSet, p_inputBrickSizeSet
which need to both be true. Their values are checked in the following functions: ProcessByBrick::PrepProcessCube,ProcessByBrick::PrepProcessCubeInPlace, and ProcessByBrick::PrepProcessCubes.

The following code (listed below) compiles but will throw the following exception if one attemps to run it: "Use the SetBrickSize(), SetInputBrickSize(), or SetOutputBrickSize() method to set the brick sizes."

`include "Isis.h"
#include "ProcessByBrick.h"
#include "ProcessBySample.h"
#include "ProcessByLine.h"
#include "SpecialPixel.h"
#include "Statistics.h"
#include "Pvl.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"

using namespace std;
using namespace Isis;

// Functor for one line/sample. Puts the difference of the current and the
// next DNs into the current for the output. Nulls the last line/sample.
class diff {
public:
diff(QString direction) {
m_direction = direction;
}

void operator()(Buffer &in, Buffer &out) const {

  double outValue;
  int current;
  int next;

  for (int i = 0; i < in.size(); i++) {
    // Get the indexes for the current and next DNs
    if (m_direction == "RIGHT") {
      current = i;
      next = current + 1;
    }
    else {
      current = (in.size() - 1) - i;
      next = current - 1;
    }

    // Calculate the output value as a difference of both inputs.
    // If either inputs are special, output is Isis::Null.
    outValue = in[current] - in[next];
    if (Isis::IsSpecial(in[current]) || Isis::IsSpecial(in[next])) {
      outValue = Isis::Null;
    }

    // Last line/sample is set to null
    if (i == in.size() - 1){
      out[current] = Isis::Null;
    }
    else {
      out[current] = outValue;
    }
  }
}

private:
QString m_direction;
};

void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
QString processType = ui.GetString("PROCESS");
QString diffDirection = ui.GetString("DIRECTION");

diff subtractor(diffDirection);
// We need parent of pbs and pbl to be converted later
ProcessByBrick *p;
ProcessByBrick *p1;

if (processType == "LINES") {
// 'new' returns pointer to object on heap
p = new ProcessByLine;

}
else {
p = new ProcessBySample;
}

// Setup the input and output cubes
p->SetInputCube("FROM");
p->SetOutputCube("TO");

p->ProcessCube(subtractor);
p->EndProcess();
}`

History

#2 Updated by Tammy Becker 8 months ago

  • Status changed from New to Acknowledged

#4 Updated by Stuart Sides 8 months ago

  • Status changed from Acknowledged to Assigned
  • Assignee set to Tyler Wilson

#5 Updated by Ian Humphrey 7 months ago

  • Story points changed from 2 to 1
  • Status changed from Assigned to In Progress

#6 Updated by Tyler Wilson 7 months ago

  • Status changed from In Progress to Resolved

#7 Updated by Ian Humphrey 7 months ago

  • Status changed from Resolved to Code Review

#8 Updated by Ian Humphrey 7 months ago

Notes:

  • Added documentation to modified methods and inline comments to explain what is going on / why the changes are needed.

  • Make sure that the unit tests and app tests pass.

  • If there is time:

    • Make sure any added/modified code is tested and update unit test accordingly. If no time, communicate with PO and potentially add new ticket to backlog.

#9 Updated by Tyler Wilson 7 months ago

  • Added inline comments to ProcessByBrick::SetBricks.
  • All system tests passed (except for the tests which are unrelated to this ticket).

#10 Updated by Tyler Wilson 7 months ago

  • Status changed from Code Review to Closed

#11 Updated by Stuart Sides 4 months ago

  • Target version changed from 3.5.1 (Sprint 1) to 3.5.1 (2017-08-08 Aug)

Also available in: Atom PDF