Commit d6d1b9f1 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Added the ability to update CSM model state in jigsaw (#4529)

* Added the ability to update CSM model state in jigsaw

* Added missing function docs

* Updated CSM jigsaw test to check apply

* Wrangled up an F
parent d1672b59
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -957,6 +957,16 @@ namespace Isis {
  }


  /**
   * Get the CSM Model state string to re-create the CSM Model.
   *
   * @returns @b QString The CSM Model state string
   */
  QString CSMCamera::getModelState() const {
    return QString::fromStdString(m_model->getModelState());
  }


  /**
   * Set the time and update the sensor position and orientation.
   *
+2 −0
Original line number Diff line number Diff line
@@ -130,6 +130,8 @@ namespace Isis {
      virtual std::vector<double> GroundPartials(SurfacePoint groundPoint);
      virtual std::vector<double> GroundPartials();

      QString getModelState() const;

    protected:
      void setTarget(Pvl label);

+20 −8
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ find files of those names at the top level of this repository. **/
#include <QSharedPointer>
#include <QString>

#include "Blob.h"
#include "BundleAdjust.h"
#include "BundleObservationSolveSettings.h"
#include "BundleResults.h"
@@ -148,15 +149,26 @@ namespace Isis {
              break;
            }

            //  Get Kernel group and add or replace LastModifiedInstrumentPointing
            //  keyword.
            Table cmatrix = bundleAdjustment->cMatrix(i);
            //  Update the image parameters
            QString jigComment = "Jigged = " + Isis::iTime::CurrentLocalTime();
            if (c->hasBlob("CSMState", "String")) {
              Blob csmStateBlob("CSMState", "String");
              // Read the BLOB from the cube to prepropagate things like the model
              // and plugin name
              c->read(csmStateBlob);
              std::string modelState = bundleAdjustment->modelState(i).toStdString();
              csmStateBlob.setData(modelState.c_str(), modelState.size());
              csmStateBlob.Label().addComment(jigComment);
              c->write(csmStateBlob);
            }
            else {
              Table cmatrix = bundleAdjustment->cMatrix(i);
              cmatrix.Label().addComment(jigComment);
              Table spvector = bundleAdjustment->spVector(i);
              spvector.Label().addComment(jigComment);
              c->write(cmatrix);
              c->write(spvector);
            }
            p.WriteHistory(*c);
          }
          gp += PvlKeyword("Status", "Camera pointing updated");
+23 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ find files of those names at the top level of this repository. **/
#include "CameraDistortionMap.h"
#include "CameraFocalPlaneMap.h"
#include "CameraGroundMap.h"
#include "CSMCamera.h"
#include "Control.h"
#include "ControlPoint.h"
#include "CorrelationMatrix.h"
@@ -2829,6 +2830,7 @@ namespace Isis {
    return m_controlNet->Camera(i)->instrumentRotation()->Cache("InstrumentPointing");
  }


  /**
   * Return a table spacecraft vector for the ith cube in the cube list given to the
   * constructor.
@@ -2842,6 +2844,27 @@ namespace Isis {
  }


  /**
   * Return the updated model state for the ith cube in the cube list given to the
   * constructor. This is only valid for CSM cubes.
   *
   * @param i The index of the cube to get the model state for
   *
   * @return @b QString The updated CSM model state string
   */
  QString BundleAdjust::modelState(int i) {
    Camera *imageCam = m_controlNet->Camera(i);
    if (imageCam->GetCameraType() != Camera::Csm) {
      QString msg = "Cannot get model state for image [" + toString(i) +
                    "] because it is not a CSM camera model.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    CSMCamera *csmCamera = dynamic_cast<CSMCamera*>(imageCam);
    return csmCamera->getModelState();
  }


  /**
   * Creates an iteration summary and an iteration group for the solution summary
   *
+1 −0
Original line number Diff line number Diff line
@@ -362,6 +362,7 @@ namespace Isis {
      bool             isConverged();
      Table            cMatrix(int index);
      Table            spVector(int index);
      QString          modelState(int index);
      int              numberOfImages() const;
      double           iteration() const;

Loading