From 84131e40f9ff3ab290161d7d63de6937eb2a6272 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Wed, 18 Nov 2020 16:05:40 -0700 Subject: [PATCH 01/12] Partial csminit code --- isis/src/base/apps/csminit/Makefile | 7 ++ isis/src/base/apps/csminit/csminit.cpp | 155 +++++++++++++++++++++++++ isis/src/base/apps/csminit/csminit.h | 12 ++ isis/src/base/apps/csminit/csminit.xml | 108 +++++++++++++++++ isis/src/base/apps/csminit/main.cpp | 28 +++++ 5 files changed, 310 insertions(+) create mode 100644 isis/src/base/apps/csminit/Makefile create mode 100644 isis/src/base/apps/csminit/csminit.cpp create mode 100644 isis/src/base/apps/csminit/csminit.h create mode 100644 isis/src/base/apps/csminit/csminit.xml create mode 100644 isis/src/base/apps/csminit/main.cpp diff --git a/isis/src/base/apps/csminit/Makefile b/isis/src/base/apps/csminit/Makefile new file mode 100644 index 0000000000..7578f0b21d --- /dev/null +++ b/isis/src/base/apps/csminit/Makefile @@ -0,0 +1,7 @@ +ifeq ($(ISISROOT), $(BLANK)) +.SILENT: +error: + echo "Please set ISISROOT"; +else + include $(ISISROOT)/make/isismake.apps +endif \ No newline at end of file diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp new file mode 100644 index 0000000000..3d96f3366b --- /dev/null +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -0,0 +1,155 @@ +#include "csminit.h" + +#include "QList.h" +#include "QString.h" +#include "QStringList.h" + +#include "Isd.h" +#include "Model.h" +#include "NitfIsd.h" +#include "Plugin.h" + +#include "Cube.h" +#include "IException.h" +#include "Process.h" +#include "Pvl.h" +#include "PvlGroup.h" +#include "PvlKeyword.h" + +using namespace std; + +namespace Isis { + + /** + * csminit a cube in an Application + * + * @param ui The Application UI + * @param(out) log The Pvl that attempted models will be logged to + */ + void csminit(UserInterface &ui, Pvl *log) { + QString isdFilePath = ui.GetFileName("ISD").expanded(); + + QList possibleModels; + for (const Plugin * plugin : csm::Plugin::getList()) { + QString pluginName = QString::fromStdString(plugin->getPluginName()); + if (ui.WasEntered("PLUGINNAME") && pluginName != ui.GetString("PLUGINNAME")) { + continue; + } + + for (size_t modelIndex = 0; modelIndex < plugin->getNumModels(); modelIndex++) { + QString modelName = QString::fromStdString(plugin->getModelName(modelIndex)); + if (ui.WasEntered("MODELNAME") && modelName != ui.GetString("MODELNAME")) { + continue; + } + + Isd fileIsd(isdFilePath.toStdString()); + if (plugin->canModelBeConstructedFromISD(fileIsd, modelName.toStdString())) { + QStringList modelSpec = {pluginName, modelName, QString::fromStdString(fileIsd.format())}; + possibleModels.append(modelSpec); + continue; // If the file ISD works, don't check the others + } + + Nitf21Isd nitf21Isd(isdFilePath.toStdString()); + if (plugin->canModelBeConstructedFromISD(nitf21Isd, modelName.toStdString())) { + QStringList modelSpec = {pluginName, modelName, QString::fromStdString(nitf21Isd.format())}; + possibleModels.append(modelSpec); + continue; // If the NITF 2.1 ISD works, don't check the others + } + } + } + + if (possibleModels.size() > 1) { + QString message = "Multiple models can be created from the ISD [" + isdFilePath + "]. " + "Re-run with the PLUGINNAME and MODELNAME parameters. " + "Possible plugin & model names:\n"; + for (const QStringList &modelSpec : possibleModels) { + message += "Plugin [" + modelSpec[0] + "], Model [" + modelSpec[1] + "]\n"; + } + throw IException(IException::User, message, _FILEINFO_); + } + + if (possibleModels.empty()) { + QString message = "No loaded model could be created from the ISD [" + isdFilePath + "]." + "Loaded plugin & model names:\n"; + for (const Plugin * plugin : csm::Plugin::getList()) { + QString pluginName = QString::fromStdString(plugin->getPluginName()); + for (size_t modelIndex = 0; modelIndex < plugin->getNumModels(); modelIndex++) { + QString modelName = QString::fromStdString(plugin->getModelName(modelIndex)); + message += "Plugin [" + pluginName + "], Model [" + modelName + "]\n"; + } + } + throw IException(IException::User, message, _FILEINFO_); + } + + // If we are here, then we have exactly 1 model + QStringList modelSpec = possibleModels.front(); + if (modelSpec.size() != 3) { + QString message = "Model specification [" + modelSpec.join(" ") + "] has [" + modelSpec.size() + "] elements " + "when it should have 3 elements."; + throw IException(IException::Programmer, message, _FILEINFO_); + } + const Plugin *plugin = Plugin::findPlugin(modelSpec[0].toStdString()); + Model *model; + Isd fileIsd(isdFilePath.toStdString()); + Nitf21Isd nitf21Isd(isdFilePath.toStdString()); + if (modelSpec[2] == QString::fromStdString(fileIsd.format())) { + model = plugin->constructModelFromISD(fileIsd, modelSpec[1].toStdString()); + } + else if (modelSpec[2] == QString::fromStdString(nitf21Isd.format())) { + model = plugin->constructModelFromISD(nitf21Isd, modelSpec[1].toStdString()); + } + else { + QString message = "Invalid ISD format specifications [" + modelSpec[2] + "]."; + throw IException(IException::Programmer, message, _FILEINFO_); + } + + string modelState = model->getModelState(); + + // We are not processing the image data, so this process object is just for + // managing the Cube in memory and adding history + Process p; + Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); + + // Really should be + // if (cube->camera()->type() == ISIS) + // + // Maybe just do spiceinit clean-up routine instead + try { + cube->camera(); + QString message = "Input cube [" + ui.GetFileName("FROM").expanded() + "]. " + "Already has an ISIS camera model associated with it. CSM " + "models cannot be added to cubes with an ISIS camera model."; + throw IException(IException::Programmer, message, _FILEINFO_); + } + catch(IException &e) { + // no operation, continue + } + + cube->deleteBlob("String", "CSMState"); + cube->deleteGroup("Instrument"); + cube->deleteGroup("Kernels"); + + PvlGroup instrumentGroup("Instrument"); + instrumentGroup += PvlKeyword("SpacecraftName", QString::fromStdString(model->getPlatformIdentifier())); + instrumentGroup += PvlKeyword("InstrumentId", QString::fromStdString(model->getSensorIdentifier())); + instrumentGroup += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); + instrumentGroup += PvlKeyword("ReferenceTime", QString::fromStdString(model->getReferenceDateAndTime())); + cube->putGroup(instrumentGroup); + + PvlGroup kernelsGroup("Kernels"); + if (ui.WasEntered("SHAPEMODEL")) { + // TODO validate the shapemodel + kernelsGroup += PvlKeyword("ShapeModel", ui.WasEntered()); + } + else { + kernelsGroup += PvlKeyword("ShapeModel", "Ellipsoid"); + } + + // Create our CSM State blob + + // Write CSM State blob to cube + + p.WriteHistory(*cube); + } + +} diff --git a/isis/src/base/apps/csminit/csminit.h b/isis/src/base/apps/csminit/csminit.h new file mode 100644 index 0000000000..9a0ad85f59 --- /dev/null +++ b/isis/src/base/apps/csminit/csminit.h @@ -0,0 +1,12 @@ +#ifndef csminit_h +#define csminit_h + + +#include "Pvl.h" +#include "UserInterface.h" + +namespace Isis { + extern void csminit(UserInterface &ui, Pvl *log=nullptr); +} + +#endif diff --git a/isis/src/base/apps/csminit/csminit.xml b/isis/src/base/apps/csminit/csminit.xml new file mode 100644 index 0000000000..756cc48c2e --- /dev/null +++ b/isis/src/base/apps/csminit/csminit.xml @@ -0,0 +1,108 @@ + + + + + Attach a CSM Model state to a cube + + + +

+ This program searches takes an ISD or state string and attempts to create + a valid CSM Model from the loaded CSM Libraries. Then, it attaches the + state string from the CSM Model to the cube for later use. If there are + multiple valid CSM Models that can be instantiated, then this program + will error and the user will have to re-run it with a specific model + and/or plugin name. +

+
+ + + Cameras + + + + + Original Version + + + + + + + cube + input + + The input cube that the state string will be attached to. + + + The input cube that the state string will be attached to. + + *.cub + + + + filename + input + + The ISD file that will be used. + + + The ISD file that will be used to create the model state string. + + + + + + + string + + The name of the body observed by the image. + + + The name of the body observed by the image. + + + + + filename + none + + The shapemodel to represent the surface of the observed body. + + + The shapemodel to represent the surface of the observed body. If none + is entered, then a bi-axial ellipsoid is used. The radii are defined + by the CSM Model. + + + + + + + string + none + + The name of the plugin to use. + + + The name of the plugin to use. The loaded CSM Libraries will be + searched for a plugin that has this name. If no such plugin is found + an error will be returned. + + + + + string + none + + The name of the model to use. + + + The name of the model to use. The loaded CSM Libraries will be + searched for a model that has this name. If no such model is found an + error will be returned. + + + + +
diff --git a/isis/src/base/apps/csminit/main.cpp b/isis/src/base/apps/csminit/main.cpp new file mode 100644 index 0000000000..e836f978c4 --- /dev/null +++ b/isis/src/base/apps/csminit/main.cpp @@ -0,0 +1,28 @@ +#include "Isis.h" + +#include "csminit.h" + +#include "Application.h" +#include "IException.h" +#include "Pvl.h" + +using namespace std; +using namespace Isis; + +void IsisMain() { + UserInterface &ui = Application::GetUserInterface(); + Pvl appLog; + try { + csminit(ui, &appLog); + } + catch (...) { + for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) { + Application::Log(*grpIt); + } + throw; + } + + for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) { + Application::Log(*grpIt); + } +} From d274a11940c46db2cdd6b255545e90afc55ae9dd Mon Sep 17 00:00:00 2001 From: Kristin Date: Thu, 19 Nov 2020 22:04:13 -0700 Subject: [PATCH 02/12] Update csminit to get compiling, update label based on discussion to store csm information in the Archive group, and write the state string out to the cube --- isis/src/base/apps/csminit/csminit.cpp | 77 ++++++++++++-------- isis/src/base/apps/csminit/csminit.xml | 2 +- isis/src/base/objs/StringBlob/Makefile | 7 ++ isis/src/base/objs/StringBlob/StringBlob.cpp | 62 ++++++++++++++++ isis/src/base/objs/StringBlob/StringBlob.h | 41 +++++++++++ 5 files changed, 159 insertions(+), 30 deletions(-) create mode 100644 isis/src/base/objs/StringBlob/Makefile create mode 100644 isis/src/base/objs/StringBlob/StringBlob.cpp create mode 100644 isis/src/base/objs/StringBlob/StringBlob.h diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index 3d96f3366b..cb1e290f82 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -1,20 +1,22 @@ #include "csminit.h" -#include "QList.h" -#include "QString.h" -#include "QStringList.h" +#include +#include +#include -#include "Isd.h" -#include "Model.h" -#include "NitfIsd.h" -#include "Plugin.h" +#include "csm/Isd.h" +#include "csm/Model.h" +#include "csm/NitfIsd.h" +#include "csm/Plugin.h" +#include "Blob.h" #include "Cube.h" #include "IException.h" #include "Process.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" +#include "StringBlob.h" using namespace std; @@ -26,11 +28,13 @@ namespace Isis { * @param ui The Application UI * @param(out) log The Pvl that attempted models will be logged to */ - void csminit(UserInterface &ui, Pvl *log) { - QString isdFilePath = ui.GetFileName("ISD").expanded(); + +void csminit(UserInterface &ui, Pvl *log) { + QString isdFilePath = ui.GetFileName("ISD"); + QList possibleModels; - for (const Plugin * plugin : csm::Plugin::getList()) { + for (const csm::Plugin * plugin : csm::Plugin::getList()) { QString pluginName = QString::fromStdString(plugin->getPluginName()); if (ui.WasEntered("PLUGINNAME") && pluginName != ui.GetString("PLUGINNAME")) { continue; @@ -42,14 +46,14 @@ namespace Isis { continue; } - Isd fileIsd(isdFilePath.toStdString()); + csm::Isd fileIsd(isdFilePath.toStdString()); if (plugin->canModelBeConstructedFromISD(fileIsd, modelName.toStdString())) { QStringList modelSpec = {pluginName, modelName, QString::fromStdString(fileIsd.format())}; possibleModels.append(modelSpec); continue; // If the file ISD works, don't check the others } - Nitf21Isd nitf21Isd(isdFilePath.toStdString()); + csm::Nitf21Isd nitf21Isd(isdFilePath.toStdString()); if (plugin->canModelBeConstructedFromISD(nitf21Isd, modelName.toStdString())) { QStringList modelSpec = {pluginName, modelName, QString::fromStdString(nitf21Isd.format())}; possibleModels.append(modelSpec); @@ -71,7 +75,7 @@ namespace Isis { if (possibleModels.empty()) { QString message = "No loaded model could be created from the ISD [" + isdFilePath + "]." "Loaded plugin & model names:\n"; - for (const Plugin * plugin : csm::Plugin::getList()) { + for (const csm::Plugin * plugin : csm::Plugin::getList()) { QString pluginName = QString::fromStdString(plugin->getPluginName()); for (size_t modelIndex = 0; modelIndex < plugin->getNumModels(); modelIndex++) { QString modelName = QString::fromStdString(plugin->getModelName(modelIndex)); @@ -88,10 +92,10 @@ namespace Isis { "when it should have 3 elements."; throw IException(IException::Programmer, message, _FILEINFO_); } - const Plugin *plugin = Plugin::findPlugin(modelSpec[0].toStdString()); - Model *model; - Isd fileIsd(isdFilePath.toStdString()); - Nitf21Isd nitf21Isd(isdFilePath.toStdString()); + const csm::Plugin *plugin = csm::Plugin::findPlugin(modelSpec[0].toStdString()); + csm::Model *model; + csm::Isd fileIsd(isdFilePath.toStdString()); + csm::Nitf21Isd nitf21Isd(isdFilePath.toStdString()); if (modelSpec[2] == QString::fromStdString(fileIsd.format())) { model = plugin->constructModelFromISD(fileIsd, modelSpec[1].toStdString()); } @@ -116,7 +120,7 @@ namespace Isis { // Maybe just do spiceinit clean-up routine instead try { cube->camera(); - QString message = "Input cube [" + ui.GetFileName("FROM").expanded() + "]. " + QString message = "Input cube [" + ui.GetFileName("FROM") + "]. " "Already has an ISIS camera model associated with it. CSM " "models cannot be added to cubes with an ISIS camera model."; throw IException(IException::Programmer, message, _FILEINFO_); @@ -126,28 +130,43 @@ namespace Isis { } cube->deleteBlob("String", "CSMState"); - cube->deleteGroup("Instrument"); - cube->deleteGroup("Kernels"); + + Pvl *label = cube->label(); - PvlGroup instrumentGroup("Instrument"); - instrumentGroup += PvlKeyword("SpacecraftName", QString::fromStdString(model->getPlatformIdentifier())); - instrumentGroup += PvlKeyword("InstrumentId", QString::fromStdString(model->getSensorIdentifier())); - instrumentGroup += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); - instrumentGroup += PvlKeyword("ReferenceTime", QString::fromStdString(model->getReferenceDateAndTime())); - cube->putGroup(instrumentGroup); + // Add the TargetName to the instrument group, if specified: + if (ui.WasEntered("TARGETNAME")) { + PvlGroup &instrumentGroup = label->findGroup("Instrument", Pvl::Traverse); + instrumentGroup += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); + } - PvlGroup kernelsGroup("Kernels"); + // Popualte the Archive group with useful information + PvlGroup &archiveGroup = label->findGroup("Archive", Pvl::Traverse); + archiveGroup += PvlKeyword("CSMPlatformID", + "FAKE");//QString::fromStdString(model->getPlatformIdentifier())); + archiveGroup += PvlKeyword("CSMInstrumentId", + "Fun test");//QString::fromStdString(model->getSensorIdentifier())); + archiveGroup += PvlKeyword("ReferenceTime", + "Thanksgiving");//QString::fromStdString(model->getReferenceDateAndTime())); + + // Update existing Kernels Group or create new one and add shapemodel if provided + PvlGroup &kernelsGroup = label->findGroup("Kernels", Pvl::Traverse); if (ui.WasEntered("SHAPEMODEL")) { // TODO validate the shapemodel - kernelsGroup += PvlKeyword("ShapeModel", ui.WasEntered()); + kernelsGroup += PvlKeyword("ShapeModel", ui.GetString("SHAPEMODEL")); } else { kernelsGroup += PvlKeyword("ShapeModel", "Ellipsoid"); } - // Create our CSM State blob + // Create our CSM State blob as a string + // Add the CSM string to the Blob. + StringBlob csmStateBlob(modelState, "CSMState"); + PvlObject &blobLabel = csmStateBlob.Label(); + blobLabel += PvlKeyword("ModelName", "ModelPumpkin");//QString::fromStdString(model->getModelName())); + blobLabel += PvlKeyword("PluginName", "TurkeyPlugin");//QString::fromStdString(plugin->getPluginName())); // Write CSM State blob to cube + cube->write(csmStateBlob); p.WriteHistory(*cube); } diff --git a/isis/src/base/apps/csminit/csminit.xml b/isis/src/base/apps/csminit/csminit.xml index 756cc48c2e..87e4f479b9 100644 --- a/isis/src/base/apps/csminit/csminit.xml +++ b/isis/src/base/apps/csminit/csminit.xml @@ -104,5 +104,5 @@ - + diff --git a/isis/src/base/objs/StringBlob/Makefile b/isis/src/base/objs/StringBlob/Makefile new file mode 100644 index 0000000000..f122bc8822 --- /dev/null +++ b/isis/src/base/objs/StringBlob/Makefile @@ -0,0 +1,7 @@ +ifeq ($(ISISROOT), $(BLANK)) +.SILENT: +error: + echo "Please set ISISROOT"; +else + include $(ISISROOT)/make/isismake.objs +endif \ No newline at end of file diff --git a/isis/src/base/objs/StringBlob/StringBlob.cpp b/isis/src/base/objs/StringBlob/StringBlob.cpp new file mode 100644 index 0000000000..957fa8dd67 --- /dev/null +++ b/isis/src/base/objs/StringBlob/StringBlob.cpp @@ -0,0 +1,62 @@ +/** + */ +#include +#include "StringBlob.h" +#include "Application.h" + +using namespace std; +namespace Isis { + /** + * Constructor for creating an string blob with no arguments + */ + StringBlob::StringBlob() : Isis::Blob("IsisCube", "String") { + m_string = ""; + } + + /** + * Constructor for creating a string blob with a file to + * read labels from. + * + * @param file File to read labels from + */ + StringBlob::StringBlob(const QString &file) : + Isis::Blob("IsisCube", "String") { + Blob::Read(file); + } + + /** + * Constructor for creating a string blob with a standard string + * + * @param string String to read/write from the cube. + */ + StringBlob::StringBlob(std::string str, QString name) : Isis::Blob(name, "String") { + m_string = str; + } + + // Destructor + StringBlob::~StringBlob() { + } + + /** + * Prepare to write string to output cube + */ + void StringBlob::WriteInit() { + p_nbytes = m_string.size(); + } + + + /** + * Writes blob data to a stream + * + * @param stream Output steam blob data will be written to + * + * @throws IException::Io - Error writing data to stream + */ + void StringBlob::WriteData(std::fstream &os) { + os.write(m_string.c_str(), p_nbytes); + if (!os.good()) { + QString msg = "Error writing data to " + p_type + " [" + p_blobName + "]"; + throw IException(IException::Io, msg, _FILEINFO_); + } + } +} diff --git a/isis/src/base/objs/StringBlob/StringBlob.h b/isis/src/base/objs/StringBlob/StringBlob.h new file mode 100644 index 0000000000..19c1731aba --- /dev/null +++ b/isis/src/base/objs/StringBlob/StringBlob.h @@ -0,0 +1,41 @@ +#ifndef StringBlob_h +#define StringBlob_h + +/** + */ + +#include + +#include "Blob.h" + +namespace Isis { + /** + * @brief Read and store std::strings on the cube. + * + * + * @ingroup LowLevelCubeIO + * + * @author 2020-11-19 Kristin Berry - Original Version + * + * @internal + * @history 2020-11-19 Kristin Berry - Original Version + */ + class StringBlob : public Isis::Blob { + public: + StringBlob(); + StringBlob(const QString &file); + StringBlob(std::string str, QString name); + ~StringBlob(); + + protected: + // prepare data for writing + void WriteInit(); + void WriteData(std::fstream &os); + + private: + std::string m_string; + }; +}; + +#endif + From c1166d3bf9ef7be5dc33c11c6184a8926a1af22f Mon Sep 17 00:00:00 2001 From: Kristin Date: Thu, 19 Nov 2020 22:06:56 -0700 Subject: [PATCH 03/12] Removed Thanksgiving-themed debug output --- isis/src/base/apps/csminit/csminit.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index cb1e290f82..905d5771f9 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -142,11 +142,11 @@ void csminit(UserInterface &ui, Pvl *log) { // Popualte the Archive group with useful information PvlGroup &archiveGroup = label->findGroup("Archive", Pvl::Traverse); archiveGroup += PvlKeyword("CSMPlatformID", - "FAKE");//QString::fromStdString(model->getPlatformIdentifier())); + QString::fromStdString(model->getPlatformIdentifier())); archiveGroup += PvlKeyword("CSMInstrumentId", - "Fun test");//QString::fromStdString(model->getSensorIdentifier())); + QString::fromStdString(model->getSensorIdentifier())); archiveGroup += PvlKeyword("ReferenceTime", - "Thanksgiving");//QString::fromStdString(model->getReferenceDateAndTime())); + QString::fromStdString(model->getReferenceDateAndTime())); // Update existing Kernels Group or create new one and add shapemodel if provided PvlGroup &kernelsGroup = label->findGroup("Kernels", Pvl::Traverse); @@ -162,8 +162,8 @@ void csminit(UserInterface &ui, Pvl *log) { // Add the CSM string to the Blob. StringBlob csmStateBlob(modelState, "CSMState"); PvlObject &blobLabel = csmStateBlob.Label(); - blobLabel += PvlKeyword("ModelName", "ModelPumpkin");//QString::fromStdString(model->getModelName())); - blobLabel += PvlKeyword("PluginName", "TurkeyPlugin");//QString::fromStdString(plugin->getPluginName())); + blobLabel += PvlKeyword("ModelName", QString::fromStdString(model->getModelName())); + blobLabel += PvlKeyword("PluginName", QString::fromStdString(plugin->getPluginName())); // Write CSM State blob to cube cube->write(csmStateBlob); From 96086f643d10997a1ffe935f4851c4e39f19d70a Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Fri, 20 Nov 2020 08:25:14 -0700 Subject: [PATCH 04/12] Updated StringBlob override methods --- isis/src/base/objs/StringBlob/StringBlob.cpp | 41 +++++++++++++++----- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/isis/src/base/objs/StringBlob/StringBlob.cpp b/isis/src/base/objs/StringBlob/StringBlob.cpp index 957fa8dd67..384747d232 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.cpp +++ b/isis/src/base/objs/StringBlob/StringBlob.cpp @@ -1,6 +1,7 @@ /** */ #include +#include #include "StringBlob.h" #include "Application.h" @@ -41,22 +42,44 @@ namespace Isis { * Prepare to write string to output cube */ void StringBlob::WriteInit() { - p_nbytes = m_string.size(); - } + int bytes = m_string.size(); + + char *temp = p_buffer; + p_buffer = new char[p_nbytes+bytes]; + if (temp != NULL) memcpy(p_buffer, temp, p_nbytes); + const char *ptr = m_string.c_str(); + memcpy(&p_buffer[p_nbytes], (void *)ptr, bytes); + p_nbytes += bytes; + if (temp != NULL) delete [] temp; + } /** - * Writes blob data to a stream + * Read binary data from an input stream into the string. * - * @param stream Output steam blob data will be written to + * @param stream The input stream to read from. * - * @throws IException::Io - Error writing data to stream + * @throws IException::Io - Error reading data from stream */ - void StringBlob::WriteData(std::fstream &os) { - os.write(m_string.c_str(), p_nbytes); - if (!os.good()) { - QString msg = "Error writing data to " + p_type + " [" + p_blobName + "]"; + void Blob::ReadData(std::istream &stream) { + // Read the binary data + if (p_buffer != NULL) delete [] p_buffer; + p_buffer = new char[p_nbytes]; + + streampos sbyte = p_startByte - 1; + stream.seekg(sbyte, std::ios::beg); + if (!stream.good()) { + QString msg = "Error preparing to read data from " + p_type + + " [" + p_blobName + "]"; throw IException(IException::Io, msg, _FILEINFO_); } + + stream.read(p_buffer, p_nbytes); + if (!stream.good()) { + QString msg = "Error reading data from " + p_type + " [" + p_blobName + "]"; + throw IException(IException::Io, msg, _FILEINFO_); + } + + m_string = QByteArray(p_buffer, p_nbytes); } } From 56d6d6d6e205145a556dd61dddd7237dd52d71df Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Fri, 20 Nov 2020 08:44:04 -0700 Subject: [PATCH 05/12] Fixed some build errors --- isis/src/base/apps/csminit/csminit.xml | 4 +++- isis/src/base/objs/StringBlob/StringBlob.cpp | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/isis/src/base/apps/csminit/csminit.xml b/isis/src/base/apps/csminit/csminit.xml index 87e4f479b9..eeda55b275 100644 --- a/isis/src/base/apps/csminit/csminit.xml +++ b/isis/src/base/apps/csminit/csminit.xml @@ -55,11 +55,13 @@ string + none The name of the body observed by the image. - The name of the body observed by the image. + The name of the body observed by the image. If not entered, then the + target already listed on the label will be used. diff --git a/isis/src/base/objs/StringBlob/StringBlob.cpp b/isis/src/base/objs/StringBlob/StringBlob.cpp index 384747d232..12a2d61623 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.cpp +++ b/isis/src/base/objs/StringBlob/StringBlob.cpp @@ -1,7 +1,6 @@ /** */ #include -#include #include "StringBlob.h" #include "Application.h" @@ -61,7 +60,7 @@ namespace Isis { * * @throws IException::Io - Error reading data from stream */ - void Blob::ReadData(std::istream &stream) { + void StringBlob::ReadData(std::istream &stream) { // Read the binary data if (p_buffer != NULL) delete [] p_buffer; p_buffer = new char[p_nbytes]; @@ -80,6 +79,6 @@ namespace Isis { throw IException(IException::Io, msg, _FILEINFO_); } - m_string = QByteArray(p_buffer, p_nbytes); + m_string = std::string(p_buffer, p_nbytes); } } From dff6740596b9bfb486f747139e0953a6d4945f76 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Fri, 20 Nov 2020 08:52:22 -0700 Subject: [PATCH 06/12] Fixed header --- isis/src/base/objs/StringBlob/StringBlob.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isis/src/base/objs/StringBlob/StringBlob.h b/isis/src/base/objs/StringBlob/StringBlob.h index 19c1731aba..8229e7f3bf 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.h +++ b/isis/src/base/objs/StringBlob/StringBlob.h @@ -30,7 +30,7 @@ namespace Isis { protected: // prepare data for writing void WriteInit(); - void WriteData(std::fstream &os); + void ReadData(std::istream &stream); private: std::string m_string; From 2a58f8b7a6111cbd108eadd15fe72f4af3349835 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Fri, 20 Nov 2020 14:25:04 -0700 Subject: [PATCH 07/12] Working? --- isis/src/base/apps/csminit/csminit.cpp | 67 ++++++++++++++++++++------ 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index 905d5771f9..0f594737c0 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "csm/Isd.h" #include "csm/Model.h" @@ -28,11 +29,18 @@ namespace Isis { * @param ui The Application UI * @param(out) log The Pvl that attempted models will be logged to */ - - -void csminit(UserInterface &ui, Pvl *log) { + void csminit(UserInterface &ui, Pvl *log) { + //TESTING LOAD USGSCSM + QLibrary usgscsm("/Users/jmapel/miniconda3/envs/isis4_build/lib/libusgscsm.dylib"); + if (usgscsm.load()) { + std::cout << "Successfully loaded usgscsm" << std::endl; + } + else { + std::cout << "Failed to load usgscsm" << std::endl; + } + //END TESTING QString isdFilePath = ui.GetFileName("ISD"); - + QList possibleModels; for (const csm::Plugin * plugin : csm::Plugin::getList()) { QString pluginName = QString::fromStdString(plugin->getPluginName()); @@ -83,6 +91,7 @@ void csminit(UserInterface &ui, Pvl *log) { } } throw IException(IException::User, message, _FILEINFO_); + // std::cout << "No model found" << std::endl; } // If we are here, then we have exactly 1 model @@ -108,6 +117,7 @@ void csminit(UserInterface &ui, Pvl *log) { } string modelState = model->getModelState(); + // string modelState = "TestModel\nThis is the test model state."; // We are not processing the image data, so this process object is just for // managing the Cube in memory and adding history @@ -129,27 +139,50 @@ void csminit(UserInterface &ui, Pvl *log) { // no operation, continue } - cube->deleteBlob("String", "CSMState"); - - Pvl *label = cube->label(); - // Add the TargetName to the instrument group, if specified: if (ui.WasEntered("TARGETNAME")) { - PvlGroup &instrumentGroup = label->findGroup("Instrument", Pvl::Traverse); - instrumentGroup += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); + if (!cube->hasGroup("Instrument")) { + cube->putGroup(PvlGroup("Instrument")); + } + PvlGroup &instrumentGroup = cube->group("Instrument"); + if (instrumentGroup.hasKeyword("TargetName")) { + instrumentGroup.deleteKeyword("TargetName"); + } + instrumentGroup += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); } // Popualte the Archive group with useful information - PvlGroup &archiveGroup = label->findGroup("Archive", Pvl::Traverse); - archiveGroup += PvlKeyword("CSMPlatformID", + if (!cube->hasGroup("Archive")) { + cube->putGroup(PvlGroup("Archive")); + } + PvlGroup &archiveGroup = cube->group("Archive"); + if (archiveGroup.hasKeyword("CSMPlatformID")) { + archiveGroup.deleteKeyword("CSMPlatformID"); + } + archiveGroup += PvlKeyword("CSMPlatformID", + // "TestPlatformID"); QString::fromStdString(model->getPlatformIdentifier())); - archiveGroup += PvlKeyword("CSMInstrumentId", + if (archiveGroup.hasKeyword("CSMInstrumentId")) { + archiveGroup.deleteKeyword("CSMInstrumentId"); + } + archiveGroup += PvlKeyword("CSMInstrumentId", + // "TestInstrumentID"); QString::fromStdString(model->getSensorIdentifier())); - archiveGroup += PvlKeyword("ReferenceTime", + if (archiveGroup.hasKeyword("ReferenceTime")) { + archiveGroup.deleteKeyword("ReferenceTime"); + } + archiveGroup += PvlKeyword("ReferenceTime", + // "TestReferenceTime"); QString::fromStdString(model->getReferenceDateAndTime())); // Update existing Kernels Group or create new one and add shapemodel if provided - PvlGroup &kernelsGroup = label->findGroup("Kernels", Pvl::Traverse); + if (!cube->hasGroup("Kernels")) { + cube->putGroup(PvlGroup("Kernels")); + } + PvlGroup &kernelsGroup = cube->group("Kernels"); + if (kernelsGroup.hasKeyword("ShapeModel")) { + kernelsGroup.deleteKeyword("ShapeModel"); + } if (ui.WasEntered("SHAPEMODEL")) { // TODO validate the shapemodel kernelsGroup += PvlKeyword("ShapeModel", ui.GetString("SHAPEMODEL")); @@ -158,11 +191,15 @@ void csminit(UserInterface &ui, Pvl *log) { kernelsGroup += PvlKeyword("ShapeModel", "Ellipsoid"); } + cube->deleteBlob("String", "CSMState"); + // Create our CSM State blob as a string // Add the CSM string to the Blob. StringBlob csmStateBlob(modelState, "CSMState"); PvlObject &blobLabel = csmStateBlob.Label(); + // blobLabel += PvlKeyword("ModelName", "TestModelName"); blobLabel += PvlKeyword("ModelName", QString::fromStdString(model->getModelName())); + // blobLabel += PvlKeyword("PluginName", "TestPluginName"); blobLabel += PvlKeyword("PluginName", QString::fromStdString(plugin->getPluginName())); // Write CSM State blob to cube From 588a72a402a67863a11641f8fdaba161f4f46c2c Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 23 Nov 2020 08:53:50 -0700 Subject: [PATCH 08/12] Now working? --- .gitignore | 3 +++ isis/src/base/apps/csminit/csminit.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index d4bc1304e7..c9ae0ef9fc 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,9 @@ install/ # Unignore the documentation build !isis/src/docsys/build +# Ignore vs code +.vscode + # Created by https://www.gitignore.io/api/macos # Edit at https://www.gitignore.io/?templates=macos diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index 0f594737c0..fea40e53b6 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -39,6 +39,12 @@ namespace Isis { std::cout << "Failed to load usgscsm" << std::endl; } //END TESTING + // We are not processing the image data, so this process object is just for + // managing the Cube in memory and adding history + Process p; + // Get the cube here so that we check early if it doesn't exist + Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); + QString isdFilePath = ui.GetFileName("ISD"); QList possibleModels; @@ -119,11 +125,6 @@ namespace Isis { string modelState = model->getModelState(); // string modelState = "TestModel\nThis is the test model state."; - // We are not processing the image data, so this process object is just for - // managing the Cube in memory and adding history - Process p; - Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); - // Really should be // if (cube->camera()->type() == ISIS) // From 348d7b31890f031dfc323e349ba4f063291583f5 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 23 Nov 2020 11:26:13 -0700 Subject: [PATCH 09/12] First pass at csmpt application --- isis/src/base/apps/csminit/csminit.cpp | 7 +- isis/src/base/apps/csmpt/Makefile | 7 ++ isis/src/base/apps/csmpt/csmpt.cpp | 98 ++++++++++++++++++++++ isis/src/base/apps/csmpt/csmpt.h | 12 +++ isis/src/base/apps/csmpt/csmpt.xml | 78 +++++++++++++++++ isis/src/base/apps/csmpt/main.cpp | 28 +++++++ isis/src/base/objs/StringBlob/StringBlob.h | 4 + 7 files changed, 230 insertions(+), 4 deletions(-) create mode 100644 isis/src/base/apps/csmpt/Makefile create mode 100644 isis/src/base/apps/csmpt/csmpt.cpp create mode 100644 isis/src/base/apps/csmpt/csmpt.h create mode 100644 isis/src/base/apps/csmpt/csmpt.xml create mode 100644 isis/src/base/apps/csmpt/main.cpp diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index fea40e53b6..833be7dc15 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -125,10 +125,7 @@ namespace Isis { string modelState = model->getModelState(); // string modelState = "TestModel\nThis is the test model state."; - // Really should be - // if (cube->camera()->type() == ISIS) - // - // Maybe just do spiceinit clean-up routine instead + // TODO Just do spiceinit clean-up routine instead try { cube->camera(); QString message = "Input cube [" + ui.GetFileName("FROM") + "]. " @@ -206,6 +203,8 @@ namespace Isis { // Write CSM State blob to cube cube->write(csmStateBlob); + // TODO attempt to get the CSM Model from the cube + p.WriteHistory(*cube); } diff --git a/isis/src/base/apps/csmpt/Makefile b/isis/src/base/apps/csmpt/Makefile new file mode 100644 index 0000000000..7578f0b21d --- /dev/null +++ b/isis/src/base/apps/csmpt/Makefile @@ -0,0 +1,7 @@ +ifeq ($(ISISROOT), $(BLANK)) +.SILENT: +error: + echo "Please set ISISROOT"; +else + include $(ISISROOT)/make/isismake.apps +endif \ No newline at end of file diff --git a/isis/src/base/apps/csmpt/csmpt.cpp b/isis/src/base/apps/csmpt/csmpt.cpp new file mode 100644 index 0000000000..df5b029c5f --- /dev/null +++ b/isis/src/base/apps/csmpt/csmpt.cpp @@ -0,0 +1,98 @@ +#include "csmpt.h" + +#include +#include +#include +#include + +#include "csm/Model.h" +#include "csm/RasterGM.h" +#include "csm/Plugin.h" + +#include "Blob.h" +#include "Cube.h" +#include "IException.h" +#include "Process.h" +#include "Pvl.h" +#include "PvlGroup.h" +#include "PvlKeyword.h" +#include "PvlObject.h" +#include "StringBlob.h" + +using namespace std; + +namespace Isis { + + /** + * csmpt + * + * @param ui The Application UI + * @param(out) log The Pvl that attempted models will be logged to + */ + void csmpt(UserInterface &ui, Pvl *log) { + //TESTING LOAD USGSCSM + QLibrary usgscsm("/Users/jmapel/miniconda3/envs/isis4_build/lib/libusgscsm.dylib"); + if (usgscsm.load()) { + std::cout << "Successfully loaded usgscsm" << std::endl; + } + else { + std::cout << "Failed to load usgscsm" << std::endl; + } + //END TESTING + // We are not processing the image data, so this process object is just for + // managing the Cube in memory and adding history + Process p; + // Get the cube here so that we check early if it doesn't exist + Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); + + StringBlob stateBlob("String", "CSMState"); + + try { + cube->read(stateBlob); + } + catch(IException &e) { + QString message = "Could not read CSM state string from input cube [" + + ui.GetFileName("FROM") + "]. Check that csminit " + "has been successfully run on it."; + throw IException(e, IException::User, message, _FILEINFO_); + } + + PvlObject stateLabel = stateBlob.Label(); + if (!stateLabel.hasKeyword("PluginName") || !stateLabel.hasKeyword("ModelName")) { + QString message = "Label for CSM State BLOB is malformed."; + throw IException(IException::Unknown, message, _FILEINFO_); + } + + QString pluginName = stateLabel.findKeyword("PluginName"); + QString modelName = stateLabel.findKeyword("ModelName"); + + const csm::Plugin *plugin = csm::Plugin::findPlugin(pluginName.toStdString()); + if (!plugin->canModelBeConstructedFromState(modelName.toStdString(), stateBlob.string())) { + QString message = "Plugin [" + pluginName + "] cannot construct model [" + + modelName + "] from state string [" + + QString::fromStdString(stateBlob.string()) + "]."; + throw IException(IException::Unknown, message, _FILEINFO_); + } + + csm::Model *model = plugin->constructModelFromState(stateBlob.string()); + csm::RasterGM *rasterModel = dynamic_cast(model); + + csm::ImageVector imageSize = rasterModel->getImageSize(); + csm::ImageCoord imagePt(imageSize.line / 2.0, imageSize.samp / 2.0); + if (ui.WasEntered("SAMPLE")) { + imagePt.samp = ui.GetDouble("SAMPLE"); + } + if (ui.WasEntered("LINE")) { + imagePt.line = ui.GetDouble("LINE"); + } + double height = 0.0; + if (ui.WasEntered("HEIGHT")) { + height = ui.GetDouble("HEIGHT"); + } + csm::EcefCoord groundPt = rasterModel->imageToGround(imagePt, height); + + std::cout << "Image point: (" << imagePt.samp << ", " << imagePt.line << ", " << height << ")" << std::endl; + std::cout << "Ground point: (" << groundPt.x << ", " << groundPt.y << ", " << groundPt.z << ")" << std::endl; + } + +} diff --git a/isis/src/base/apps/csmpt/csmpt.h b/isis/src/base/apps/csmpt/csmpt.h new file mode 100644 index 0000000000..0b44c03b5a --- /dev/null +++ b/isis/src/base/apps/csmpt/csmpt.h @@ -0,0 +1,12 @@ +#ifndef csmpt_h +#define csmpt_h + + +#include "Pvl.h" +#include "UserInterface.h" + +namespace Isis { + extern void csmpt(UserInterface &ui, Pvl *log=nullptr); +} + +#endif diff --git a/isis/src/base/apps/csmpt/csmpt.xml b/isis/src/base/apps/csmpt/csmpt.xml new file mode 100644 index 0000000000..e14fff8346 --- /dev/null +++ b/isis/src/base/apps/csmpt/csmpt.xml @@ -0,0 +1,78 @@ + + + + + Load a CSM model and run imageToGround at a specified pixel. + + + +

+ This program loads the CSM model that has been attached to a cube via csminit + and then runs imageToGround to generate a ground point at a specified pixel. +

+
+ + + Cameras + + + + + Original Version + + + + + + + cube + input + + The input cube that has a CSM model attached. + + + The input cube that has a CSM model attached. + + *.cub + + + + + + double + center sample + + The sample to run imageToGround on. + + + The sample to run imageToGround on. If not specified then the center + sample of the image will be used. + + + + + double + center line + + The line to run imageToGround on. + + + The line to run imageToGround on. If not specified then the center + line of the image will be used. + + + + + double + center line + + The height above the ellipsoid to intersect at. + + + The height above the ellipsoid to intersect at. If not specified then + the ellipsoid will be intersected directly. + + + + +
diff --git a/isis/src/base/apps/csmpt/main.cpp b/isis/src/base/apps/csmpt/main.cpp new file mode 100644 index 0000000000..5a3d263686 --- /dev/null +++ b/isis/src/base/apps/csmpt/main.cpp @@ -0,0 +1,28 @@ +#include "Isis.h" + +#include "csmpt.h" + +#include "Application.h" +#include "IException.h" +#include "Pvl.h" + +using namespace std; +using namespace Isis; + +void IsisMain() { + UserInterface &ui = Application::GetUserInterface(); + Pvl appLog; + try { + csmpt(ui, &appLog); + } + catch (...) { + for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) { + Application::Log(*grpIt); + } + throw; + } + + for (auto grpIt = appLog.beginGroup(); grpIt!= appLog.endGroup(); grpIt++) { + Application::Log(*grpIt); + } +} diff --git a/isis/src/base/objs/StringBlob/StringBlob.h b/isis/src/base/objs/StringBlob/StringBlob.h index 8229e7f3bf..d3bc05f246 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.h +++ b/isis/src/base/objs/StringBlob/StringBlob.h @@ -27,6 +27,10 @@ namespace Isis { StringBlob(std::string str, QString name); ~StringBlob(); + std::string string() { + return m_string; + } + protected: // prepare data for writing void WriteInit(); From 881acc9e56d0f33c202f78b80146ed83387ae175 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Mon, 23 Nov 2020 13:11:58 -0700 Subject: [PATCH 10/12] Better error checking --- isis/src/base/apps/csmpt/csmpt.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/isis/src/base/apps/csmpt/csmpt.cpp b/isis/src/base/apps/csmpt/csmpt.cpp index df5b029c5f..e10fa597d0 100644 --- a/isis/src/base/apps/csmpt/csmpt.cpp +++ b/isis/src/base/apps/csmpt/csmpt.cpp @@ -43,12 +43,12 @@ namespace Isis { // managing the Cube in memory and adding history Process p; // Get the cube here so that we check early if it doesn't exist - Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); + Cube cube(ui.GetFileName("FROM")); StringBlob stateBlob("String", "CSMState"); try { - cube->read(stateBlob); + cube.read(stateBlob); } catch(IException &e) { QString message = "Could not read CSM state string from input cube [" + @@ -67,6 +67,14 @@ namespace Isis { QString modelName = stateLabel.findKeyword("ModelName"); const csm::Plugin *plugin = csm::Plugin::findPlugin(pluginName.toStdString()); + if (!plugin) { + QString message = "Could not find plugin [" + pluginName + "] to instantiate " + "model from. Loaded plugins:\n"; + for (const csm::Plugin * plugin : csm::Plugin::getList()) { + message += QString::fromStdString(plugin->getPluginName()) + "\n"; + } + throw IException(IException::User, message, _FILEINFO_); + } if (!plugin->canModelBeConstructedFromState(modelName.toStdString(), stateBlob.string())) { QString message = "Plugin [" + pluginName + "] cannot construct model [" + modelName + "] from state string [" + From 9a8d9db73cb9807447ee468751b09b65d06ea833 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Tue, 24 Nov 2020 12:45:55 -0700 Subject: [PATCH 11/12] Modified to use the plugin specification --- isis/src/base/apps/csminit/csminit.cpp | 22 +++++++++++++--------- isis/src/base/apps/csmpt/csmpt.cpp | 22 +++++++++++++--------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index 833be7dc15..0e0d6634ec 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -11,6 +11,8 @@ #include "csm/Plugin.h" #include "Blob.h" +#include "Camera.h" +#include "CameraFactory.h" #include "Cube.h" #include "IException.h" #include "Process.h" @@ -30,21 +32,23 @@ namespace Isis { * @param(out) log The Pvl that attempted models will be logged to */ void csminit(UserInterface &ui, Pvl *log) { - //TESTING LOAD USGSCSM - QLibrary usgscsm("/Users/jmapel/miniconda3/envs/isis4_build/lib/libusgscsm.dylib"); - if (usgscsm.load()) { - std::cout << "Successfully loaded usgscsm" << std::endl; - } - else { - std::cout << "Failed to load usgscsm" << std::endl; - } - //END TESTING // We are not processing the image data, so this process object is just for // managing the Cube in memory and adding history Process p; // Get the cube here so that we check early if it doesn't exist Cube *cube = p.SetInputCube(ui.GetFileName("FROM"), ui.GetInputAttribute("FROM"), ReadWrite); + // TESTING + // We have to call this to get the plugin list loaded right now + try { + Camera *cam = CameraFactory::Create(*cube); + delete cam; + } + catch(...) { + // Noop + } + // END TESTING + QString isdFilePath = ui.GetFileName("ISD"); QList possibleModels; diff --git a/isis/src/base/apps/csmpt/csmpt.cpp b/isis/src/base/apps/csmpt/csmpt.cpp index e10fa597d0..01c3af3269 100644 --- a/isis/src/base/apps/csmpt/csmpt.cpp +++ b/isis/src/base/apps/csmpt/csmpt.cpp @@ -10,6 +10,8 @@ #include "csm/Plugin.h" #include "Blob.h" +#include "Camera.h" +#include "CameraFactory.h" #include "Cube.h" #include "IException.h" #include "Process.h" @@ -30,21 +32,23 @@ namespace Isis { * @param(out) log The Pvl that attempted models will be logged to */ void csmpt(UserInterface &ui, Pvl *log) { - //TESTING LOAD USGSCSM - QLibrary usgscsm("/Users/jmapel/miniconda3/envs/isis4_build/lib/libusgscsm.dylib"); - if (usgscsm.load()) { - std::cout << "Successfully loaded usgscsm" << std::endl; - } - else { - std::cout << "Failed to load usgscsm" << std::endl; - } - //END TESTING // We are not processing the image data, so this process object is just for // managing the Cube in memory and adding history Process p; // Get the cube here so that we check early if it doesn't exist Cube cube(ui.GetFileName("FROM")); + // TESTING + // We have to call this to get the plugin list loaded right now + try { + Camera *cam = CameraFactory::Create(cube); + delete cam; + } + catch(...) { + // Noop + } + // END TESTING + StringBlob stateBlob("String", "CSMState"); try { From 35673ecee3307279bb4cf69f15cbacc63710a1f4 Mon Sep 17 00:00:00 2001 From: Jesse Mapel Date: Tue, 24 Nov 2020 17:22:34 -0700 Subject: [PATCH 12/12] Addressed PR comments --- isis/src/base/apps/csminit/csminit.cpp | 8 +++++++- isis/src/base/apps/csminit/csminit.h | 6 ++++++ isis/src/base/apps/csminit/csminit.xml | 4 ++-- isis/src/base/apps/csminit/main.cpp | 7 +++++++ isis/src/base/apps/csmpt/csmpt.cpp | 8 +++++++- isis/src/base/apps/csmpt/csmpt.h | 6 ++++++ isis/src/base/apps/csmpt/main.cpp | 7 +++++++ isis/src/base/objs/StringBlob/StringBlob.cpp | 9 +++++++-- isis/src/base/objs/StringBlob/StringBlob.h | 9 +++++++-- 9 files changed, 56 insertions(+), 8 deletions(-) diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index 0e0d6634ec..2951151cb1 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -1,9 +1,15 @@ +/** 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 "csminit.h" #include #include #include -#include #include "csm/Isd.h" #include "csm/Model.h" diff --git a/isis/src/base/apps/csminit/csminit.h b/isis/src/base/apps/csminit/csminit.h index 9a0ad85f59..dc861d7965 100644 --- a/isis/src/base/apps/csminit/csminit.h +++ b/isis/src/base/apps/csminit/csminit.h @@ -1,6 +1,12 @@ #ifndef csminit_h #define csminit_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 "Pvl.h" #include "UserInterface.h" diff --git a/isis/src/base/apps/csminit/csminit.xml b/isis/src/base/apps/csminit/csminit.xml index eeda55b275..a8f5a7812e 100644 --- a/isis/src/base/apps/csminit/csminit.xml +++ b/isis/src/base/apps/csminit/csminit.xml @@ -7,7 +7,7 @@

- This program searches takes an ISD or state string and attempts to create + This program takes an ISD or state string and attempts to create a valid CSM Model from the loaded CSM Libraries. Then, it attaches the state string from the CSM Model to the cube for later use. If there are multiple valid CSM Models that can be instantiated, then this program @@ -21,7 +21,7 @@ - + Original Version diff --git a/isis/src/base/apps/csminit/main.cpp b/isis/src/base/apps/csminit/main.cpp index e836f978c4..f113ef57ab 100644 --- a/isis/src/base/apps/csminit/main.cpp +++ b/isis/src/base/apps/csminit/main.cpp @@ -1,3 +1,10 @@ +/** 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 "Isis.h" #include "csminit.h" diff --git a/isis/src/base/apps/csmpt/csmpt.cpp b/isis/src/base/apps/csmpt/csmpt.cpp index 01c3af3269..ed99871735 100644 --- a/isis/src/base/apps/csmpt/csmpt.cpp +++ b/isis/src/base/apps/csmpt/csmpt.cpp @@ -1,9 +1,15 @@ +/** 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 "csmpt.h" #include #include #include -#include #include "csm/Model.h" #include "csm/RasterGM.h" diff --git a/isis/src/base/apps/csmpt/csmpt.h b/isis/src/base/apps/csmpt/csmpt.h index 0b44c03b5a..3cb7bdb775 100644 --- a/isis/src/base/apps/csmpt/csmpt.h +++ b/isis/src/base/apps/csmpt/csmpt.h @@ -1,6 +1,12 @@ #ifndef csmpt_h #define csmpt_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 "Pvl.h" #include "UserInterface.h" diff --git a/isis/src/base/apps/csmpt/main.cpp b/isis/src/base/apps/csmpt/main.cpp index 5a3d263686..cbe5f9f497 100644 --- a/isis/src/base/apps/csmpt/main.cpp +++ b/isis/src/base/apps/csmpt/main.cpp @@ -1,3 +1,10 @@ +/** 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 "Isis.h" #include "csmpt.h" diff --git a/isis/src/base/objs/StringBlob/StringBlob.cpp b/isis/src/base/objs/StringBlob/StringBlob.cpp index 12a2d61623..4d6a310929 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.cpp +++ b/isis/src/base/objs/StringBlob/StringBlob.cpp @@ -1,5 +1,10 @@ -/** - */ +/** 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 #include "StringBlob.h" #include "Application.h" diff --git a/isis/src/base/objs/StringBlob/StringBlob.h b/isis/src/base/objs/StringBlob/StringBlob.h index d3bc05f246..ab0723b4b6 100644 --- a/isis/src/base/objs/StringBlob/StringBlob.h +++ b/isis/src/base/objs/StringBlob/StringBlob.h @@ -1,8 +1,13 @@ #ifndef StringBlob_h #define StringBlob_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