Unverified Commit 8a6c8fd0 authored by Tim Giroux's avatar Tim Giroux Committed by GitHub
Browse files

Marciflip gtest (#4431)

* app conversion

* add test data and working test case

* move data

* compare framelets
parent c9083b2d
Loading
Loading
Loading
Loading
+3 −56
Original line number Diff line number Diff line
@@ -7,66 +7,13 @@ find files of those names at the top level of this repository. **/
/* SPDX-License-Identifier: CC0-1.0 */

#include "Isis.h"
#include "ProcessImportPds.h"
#include "FileName.h"
#include "Brick.h"
#include "ProcessByBrick.h"
#include "OriginalLabel.h"
#include "IException.h"
#include "UserInterface.h"
#include "marciflip.h"

using namespace std;
using namespace Isis;

Isis::Cube *outputCube = NULL;
int currentLine;
int filterHeight = 16;

void flipCube(Isis::Buffer &data);

void IsisMain() {
  ProcessByBrick p;

  Cube *icube = p.SetInputCube("FROM");

  filterHeight = 16 / (int)icube->group("Instrument")["SummingMode"];
  p.SetBrickSize(icube->sampleCount(), filterHeight, icube->bandCount());
  currentLine = icube->lineCount();

  UserInterface &ui = Application::GetUserInterface();
  outputCube = new Isis::Cube();
  outputCube->setDimensions(icube->sampleCount(), icube->lineCount(), icube->bandCount());
  outputCube->create(ui.GetFileName("TO"));

  if(icube->hasGroup("Instrument")) {
    PvlGroup inst = icube->group("Instrument");

    // change flipped keyword
    inst["DataFlipped"] = toString(((int)inst["DataFlipped"] + 1) % 2);

    outputCube->label()->findObject("IsisCube").addGroup(inst);
  }

  if(icube->hasGroup("BandBin")) {
    outputCube->label()->findObject("IsisCube").addGroup(
        icube->group("BandBin"));
  }

  if(icube->label()->hasObject("OriginalLabel")) {
    OriginalLabel origLabel = icube->readOriginalLabel();
    outputCube->write(origLabel);
  }

  p.StartProcess(flipCube);
  p.EndProcess();

  outputCube->close();
  delete outputCube;
}

void flipCube(Isis::Buffer &data) {
  currentLine -= filterHeight;
  Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType());
  outBrick.Copy(data);
  outBrick.SetBasePosition(1, currentLine + 1, data.Band());
  outputCube->write(outBrick);
  marciflip(ui);
}
+84 −0
Original line number Diff line number Diff line
/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "ProcessImportPds.h"
#include "FileName.h"
#include "Brick.h"
#include "ProcessByBrick.h"
#include "OriginalLabel.h"
#include "IException.h"
#include "marciflip.h"

using namespace std;

Isis::Cube *outputCube = NULL;
int currentLine;
int filterHeight = 16;

void flipCube(Isis::Buffer &data);

namespace Isis {

    void marciflip(UserInterface &ui) {

        Isis::ProcessByBrick p;
        QString cubeFn;
        Isis::Cube *icube;
        Isis::CubeAttributeInput inAtt;

        cubeFn = ui.GetFileName("FROM");
        icube = new Cube(cubeFn);
        inAtt = ui.GetInputAttribute("FROM");

        p.SetInputCube(cubeFn, inAtt);

        filterHeight = 16 / (int)icube->group("Instrument")["SummingMode"];

        p.SetBrickSize(icube->sampleCount(), filterHeight, icube->bandCount());

        currentLine = icube->lineCount();

        outputCube = new Cube();
        outputCube->setDimensions(icube->sampleCount(), icube->lineCount(), icube->bandCount());

        outputCube->create(ui.GetFileName("TO"));

        if(icube->hasGroup("Instrument")) {
            PvlGroup inst = icube->group("Instrument");

            // change flipped keyword
            inst["DataFlipped"] = toString(((int)inst["DataFlipped"] + 1) % 2);

            outputCube->label()->findObject("IsisCube").addGroup(inst);
        }

        if(icube->hasGroup("BandBin")) {
            outputCube->label()->findObject("IsisCube").addGroup(
                icube->group("BandBin"));
        }

        if(icube->label()->hasObject("OriginalLabel")) {
            OriginalLabel origLabel = icube->readOriginalLabel();
            outputCube->write(origLabel);
        }

        p.StartProcess(flipCube);
        p.EndProcess();

        outputCube->close();
        delete outputCube;
    }
}

void flipCube(Isis::Buffer &data) {
    currentLine -= filterHeight;
    Isis::Brick outBrick(data.SampleDimension(), data.LineDimension(), data.BandDimension(), data.PixelType());
    outBrick.Copy(data);
    outBrick.SetBasePosition(1, currentLine + 1, data.Band());
    outputCube->write(outBrick);
}
+18 −0
Original line number Diff line number Diff line
#ifndef marciflip_h
#define marciflip_h

/** This is free and unencumbered software released into the public domain.

The authors of ISIS do not claim copyright on the contents of this file.
For more details about the LICENSE terms and the AUTHORS, you will
find files of those names at the top level of this repository. **/

/* SPDX-License-Identifier: CC0-1.0 */

#include "UserInterface.h"

namespace Isis{
  extern void marciflip(UserInterface &ui);
}

#endif
+0 −4
Original line number Diff line number Diff line
BLANKS = "%-6s"    
LENGTH = "%-40s"

include $(ISISROOT)/make/isismake.tststree
+0 −8
Original line number Diff line number Diff line
APPNAME = marciflip

include $(ISISROOT)/make/isismake.tsts

commands:
	$(APPNAME) FROM=$(INPUT)/T02_001002_1200_MC_00N284W.cub \
	TO=$(OUTPUT)/flipped.cub > /dev/null;
	catlab FROM=$(OUTPUT)/flipped.cub to=$(OUTPUT)/flipped.pvl > /dev/null;
Loading