Skip to content

Commit

Permalink
Ckwriter App and Test Update (#4126)
Browse files Browse the repository at this point in the history
* Convert ckwriter to new app format

* Updated ckwriter tests to gtest and fixed angular velocities in the ThreeImageNetwork fixture

* Removed old/unnecessary includes

* Removed old ckwriter test makefiles
  • Loading branch information
acpaquette authored Nov 19, 2020
1 parent 7552d12 commit ca28b9c
Show file tree
Hide file tree
Showing 14 changed files with 325 additions and 253 deletions.
85 changes: 85 additions & 0 deletions isis/src/base/apps/ckwriter/ckwriter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <cmath>

#include "ckwriter.h"

#include "Cube.h"
#include "FileList.h"
#include "Process.h"
#include "Pvl.h"
#include "SpiceKernel.h"

using namespace std;

namespace Isis {
void ckwriter(UserInterface &ui, Pvl *log) {
Process p;

// Get the list of names of input CCD cubes to stitch together
FileList flist;
if (ui.WasEntered("FROM")) flist.push_back(FileName(ui.GetFileName("FROM")));
if (ui.WasEntered("FROMLIST")) flist.read(FileName(ui.GetFileName("FROMLIST")));
if (flist.size() < 1) {
QString msg = "Files must be specified in FROM and/or FROMLIST - none found!";
throw IException(IException::User,msg,_FILEINFO_);
}

bool overlap_is_error = ( "ERROR" == ui.GetString("OVERLAP") ) ? true : false;

SpiceKernel kernel;
Progress prog;
prog.SetMaximumSteps(flist.size());
prog.CheckStatus();

for (int i = 0 ; i < flist.size() ; i++) {
// Add and process each image
kernel.add(flist[i].toString());
prog.CheckStatus();
}

try {
kernel.validate();
}
catch ( IException &ie ) {

// Check for user preference in treatment overlaps
if ( overlap_is_error ) { throw; }

// Log it to file
Pvl overrors = ie.toPvl();
for(int i = 0; i < overrors.groups(); i++) {
PvlGroup overlap = overrors.group(i);
overlap.setName("Overlaps");
overlap.addKeyword(PvlKeyword("Class", "WARNING"), PvlContainer::Replace);
if (log) {
log->addGroup(overlap);
}
}
}


// Get comment file
QString comfile("");
if (ui.WasEntered("COMFILE")) comfile = ui.GetFileName("COMFILE");

// Write the output file if requested
if (ui.WasEntered("TO")) {
int cktype = ui.GetInteger("CKTYPE");
kernel.write(ui.GetFileName("TO"), comfile, cktype);
}

// Write a summary of the documentation
if (ui.WasEntered("SUMMARY")) {
QString fFile = FileName(ui.GetFileName("SUMMARY")).expanded();
ofstream os;
os.open(fFile.toLatin1().data(),ios::out);
if (!os) {
QString mess = "Cannot create SUMMARY output file " + fFile;
throw IException(IException::User, mess, _FILEINFO_);
}
os << kernel.getSummary(comfile);
os.close();
}

p.EndProcess();
}
}
11 changes: 11 additions & 0 deletions isis/src/base/apps/ckwriter/ckwriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef ckwriter_h
#define ckwriter_h

#include "Pvl.h"
#include "UserInterface.h"

namespace Isis{
void ckwriter(UserInterface &ui, Pvl *log=nullptr);
}

#endif
80 changes: 12 additions & 68 deletions isis/src/base/apps/ckwriter/main.cpp
Original file line number Diff line number Diff line change
@@ -1,83 +1,27 @@
#include <cmath>

#include "Isis.h"
#include "FileList.h"
#include "Cube.h"
#include "Process.h"

#include "ckwriter.h"

#include "Application.h"
#include "Pvl.h"
#include "SpiceKernel.h"
#include "CkSpiceSegment.h"

using namespace std;
using namespace Isis;

void IsisMain() {
Process p;

// Get the list of names of input CCD cubes to stitch together
FileList flist;
UserInterface &ui = Application::GetUserInterface();
if (ui.WasEntered("FROM")) flist.push_back(FileName(ui.GetFileName("FROM")));
if (ui.WasEntered("FROMLIST")) flist.read(FileName(ui.GetFileName("FROMLIST")));
if (flist.size() < 1) {
QString msg = "Files must be specified in FROM and/or FROMLIST - none found!";
throw IException(IException::User,msg,_FILEINFO_);
}

bool overlap_is_error = ( "ERROR" == ui.GetString("OVERLAP") ) ? true : false;

SpiceKernel kernel;
Progress prog;
prog.SetMaximumSteps(flist.size());
prog.CheckStatus();

for (int i = 0 ; i < flist.size() ; i++) {
// Add and process each image
kernel.add(flist[i].toString());
prog.CheckStatus();
}

Pvl appLog;
try {
kernel.validate();
ckwriter(ui, &appLog);
}
catch ( IException &ie ) {

// Check for user preference in treatment overlaps
if ( overlap_is_error ) { throw; }

// Log it to file
Pvl overrors = ie.toPvl();
for(int i = 0; i < overrors.groups(); i++) {
PvlGroup overlap = overrors.group(i);
overlap.setName("Overlaps");
overlap.addKeyword(PvlKeyword("Class", "WARNING"), PvlContainer::Replace);
Application::Log(overlap);
catch (...) {
for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) {
Application::Log(*grpIt);
}
throw;
}


// Get comment file
QString comfile("");
if (ui.WasEntered("COMFILE")) comfile = ui.GetFileName("COMFILE");

// Write the output file if requested
if (ui.WasEntered("TO")) {
int cktype = ui.GetInteger("CKTYPE");
kernel.write(ui.GetFileName("TO"), comfile, cktype);
for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) {
Application::Log(*grpIt);
}

// Write a summary of the documentation
if (ui.WasEntered("SUMMARY")) {
QString fFile = FileName(ui.GetFileName("SUMMARY")).expanded();
ofstream os;
os.open(fFile.toLatin1().data(),ios::out);
if (!os) {
QString mess = "Cannot create SUMMARY output file " + fFile;
throw IException(IException::User, mess, _FILEINFO_);
}
os << kernel.getSummary(comfile);
os.close();
}

p.EndProcess();
}
4 changes: 0 additions & 4 deletions isis/src/base/apps/ckwriter/tsts/Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions isis/src/base/apps/ckwriter/tsts/cassini/Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions isis/src/base/apps/ckwriter/tsts/hirise/Makefile

This file was deleted.

56 changes: 0 additions & 56 deletions isis/src/base/apps/ckwriter/tsts/lronac/Makefile

This file was deleted.

33 changes: 0 additions & 33 deletions isis/src/base/apps/ckwriter/tsts/messenger/Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions isis/src/base/apps/ckwriter/tsts/themis/Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions isis/src/base/apps/ckwriter/tsts/themis_nadir/Makefile

This file was deleted.

Loading

0 comments on commit ca28b9c

Please sign in to comment.