Unverified Commit 0bc124db authored by jcwbacker's avatar jcwbacker Committed by GitHub
Browse files

Merge pull request #44 from cneubauerUSGS/m05242

Improved likelihood of finding intersection using EquatorialCylindricalShape (DTMs) by using local maximum radius as the starting radius for the iterative process.  Fixes #5242
parents 855274c1 15fd66af
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
#include "EquatorialCylindricalShape.h"

#include <QDebug>
#include <QVector>

#include <algorithm>
#include <cfloat>
@@ -20,6 +21,8 @@
// #include "LinearAlgebra.h"
#include "Longitude.h"
#include "NaifStatus.h"
#include "Spice.h"
#include "ShapeModel.h"
#include "SpecialPixel.h"
#include "SurfacePoint.h"
#include "Table.h"
@@ -28,7 +31,10 @@ using namespace std;

#define MAX(x,y) (((x) > (y)) ? (x) : (y))


namespace Isis {


  /**
   * Initialize the Isis3 Equatorial Cylindrical shape model.
   *
@@ -407,8 +413,26 @@ namespace Isis {

    }

    // Do nothing since the DEM intersection was already successful
    setHasIntersection(true);
    return hasIntersection();
  }
  // Do nothing since the DEM intersection was already successful


  /**
   * Override of virtual function for intersectEllipsoid
   *
   * @return QVector holding three SpiceDoubles: SpiceDouble a, SpiceDouble b, SpiceDouble c
   */
  QVector<SpiceDouble> EquatorialCylindricalShape::setTargetRadii() {
    QVector<SpiceDouble> spiceVector(3);
    SpiceDouble a = m_maxRadius->kilometers();
    SpiceDouble b = m_maxRadius->kilometers();
    SpiceDouble c = m_maxRadius->kilometers();
    spiceVector.insert(0, a);
    spiceVector.insert(1, b);
    spiceVector.insert(2, c);
    return spiceVector;
  }

}
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@

#include "DemShape.h"

#include <QVector>

#include "Spice.h"
namespace Isis {
  class Pvl;

@@ -50,6 +53,11 @@ namespace Isis {
   *   @history 2018-01-05 Cole Neubauer - Fixed units conversion in intersectSurface so that the
   *                           loop is stepping by radians per pixel, as recommended by Jeff
   *                           Anderson (LROC team). Fixes #5245
   *   @history 2018-02-05 Cole Neubauer - Added the setTargetRadii virtual method so that the
   *                           intersectEllipsoid method can use the MaximumRadius found in the
   *                           ShapeModelStatistics group of the labels (often written during a run of
   *                           demprep) as a starting radius for the ellipsoid as opposed to the
   *                           default radius of the target. Fixes #5242
   */
  class EquatorialCylindricalShape : public DemShape {
    public:
@@ -63,6 +71,10 @@ namespace Isis {
      bool intersectSurface(std::vector<double> observerPos,
                            std::vector<double> lookDirection);

    protected:
      virtual QVector<SpiceDouble> setTargetRadii(); // returns a QVector of SpiceDouble


    private:
      Distance *m_minRadius;  //!< Minimum radius value in DEM file
      Distance *m_maxRadius;  //!< Maximum radius value in DEM file
+53 −32
Original line number Diff line number Diff line
#include "ShapeModel.h"

#include <QDebug>
#include <QVector>

#include <algorithm>
#include <cfloat>
@@ -199,6 +200,25 @@ namespace Isis {
  }


  /**
   * Override of virtual function for intersectEllipsoid
   *
   * @return QVector of three SpiceDoubles: SpiceDouble a, SpiceDouble b, SpiceDouble c
   */
  QVector<SpiceDouble> ShapeModel::setTargetRadii() {
    QVector<SpiceDouble> spiceVector(3);
    // get target radii
    std::vector<Distance> radii = targetRadii();
    SpiceDouble a = radii[0].kilometers();
    SpiceDouble b = radii[1].kilometers();
    SpiceDouble c = radii[2].kilometers();
    spiceVector.insert(0, a);
    spiceVector.insert(1, b);
    spiceVector.insert(2, c);
    return spiceVector;
  }


  /**
   * Returns the status of the ellipsoid model intersection.
   *
@@ -273,10 +293,11 @@ namespace Isis {
    memcpy(lookB,&observerLookVectorToTarget[0], 3*sizeof(double));

    // get target radii
    std::vector<Distance> radii = targetRadii();
    SpiceDouble a = radii[0].kilometers();
    SpiceDouble b = radii[1].kilometers();
    SpiceDouble c = radii[2].kilometers();
    QVector<SpiceDouble> spiceVector = setTargetRadii();

    SpiceDouble a = spiceVector.at(0);
    SpiceDouble b = spiceVector.at(1);
    SpiceDouble c = spiceVector.at(2);

    // check if observer look vector intersects the target
    SpiceDouble intersectionPoint[3];
+25 −13
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
 */

#include <vector>
#include <QVector>

#include "Spice.h"

template<class T> class QVector;

@@ -74,6 +77,11 @@ namespace Isis {
   *                           setSurfacePoint() & clearSurfacePoint() virtual
   *                           to give some hope of a consistent internal state
   *                           in derived models.
   *   @history 2018-02-05 Cole Neubauer - added virtual method setTargetRadii to be
   *                           called from intersectEllipsoid. This is to avoid
   *                           redundant code that comes with having intersectEllipsoid be
   *                           virtual as the only code that was changed will now be handled
   *                           in setTargetRadii Fixes #5242
   */
  class ShapeModel {
    public:
@@ -164,20 +172,24 @@ namespace Isis {
                                 const std::vector<double> lookDirection);

    protected:
      virtual QVector<SpiceDouble> setTargetRadii(); // returns a QVector of SpiceDouble

      // Set the normal (surface or local) of the current intersection point
      void setNormal(const std::vector<double>);
      void setNormal(const double a, const double b, const double c);

      // accessor for m_hasEllipsoidIntersection
      bool hasEllipsoidIntersection();

      // Set shape name
      void setName(QString name);

      void calculateEllipsoidalSurfaceNormal();
      bool hasEllipsoidIntersection();

      // Intersect ellipse
      bool intersectEllipsoid( const std::vector<double> observerPosRelativeToTarget,
                               const std::vector<double> &observerLookVectorToTarget);

      bool hasValidTarget() const;
      std::vector<Distance> targetRadii() const;
      void setHasNormal(bool status);