Commit 3d82fb09 authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Made improvements to documentation and brought code closer to ISIS coding...

Made improvements to documentation and brought code closer to ISIS coding standards. Removed check for ellipsoid intersection in EquatorialCylindricalShape::intersectSurface() to prevent early return and attempt the iterative method even when the ellipsoid is not intersected. Fixes #1438

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6388 41f8697f-d340-4b68-9986-7bafba869bb8
parent 74d5bc5f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2242,7 +2242,7 @@ namespace Isis {
      SetImage(0.5, 0.5);
      double etStart = time().Et();
      SetImage(p_alphaCube->BetaSamples() + 0.5,
               p_alphaCube->BetaLines() + 0.5);
               p_alphaCube->BetaLines() + 0.5); // need to do something if SetImage returns false???
      double etEnd = time().Et();
      if (band == 1) {
        startTime = min(etStart, etEnd);
+148 −192

File changed.

Preview size limit exceeded, changes collapsed.

+75 −37
Original line number Diff line number Diff line
@@ -34,9 +34,9 @@
#include "IException.h"
#include "iTime.h"
#include "Longitude.h"
#include "PvlGroup.h"
#include "SpecialPixel.h"
#include "TProjection.h"
#include "PvlGroup.h"

using namespace Isis;
using namespace std;
@@ -45,8 +45,7 @@ namespace Isis {


  /**
   * Constructor, initializes CubeManager and other variables for
   * use.
   * Constructor, initializes CubeManager and other variables for use.
   *
   */
  CameraPointInfo::CameraPointInfo() {
@@ -57,6 +56,7 @@ namespace Isis {
    m_camera = NULL;
  }


  /**
   * Destructor, deletes CubeManager object used.
   *
@@ -70,11 +70,11 @@ namespace Isis {


  /**
   * SetCube opens the given cube in a CubeManager. The
   * CubeManager is for effeciency when working with control nets
   * where cubes are accesed multiple times.
   * SetCube opens the given cube in a CubeManager. 
   * The CubeManager is for effeciency when working with control 
   * nets where cubes are accesed multiple times. 
   *
   * @param cubeFileName A cube filename
   * @param cubeFileName A cube file name.
   */
  void CameraPointInfo::SetCube(const QString &cubeFileName) {
    m_currentCube = m_usedCubes->OpenCube(cubeFileName);
@@ -86,33 +86,41 @@ namespace Isis {
   * SetImage sets a sample, line image coordinate in the camera
   * so data can be accessed.
   *
   * @param sample A sample coordinate in or almost in the cube
   * @param line A line coordinate in or almost in the cubei
   * @param sample A sample coordinate in or almost in the cube.
   * @param line A line coordinate in or almost in the cube.
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *
   * @return PvlGroup* The pertinent data from the Camera class on
   *         the point. Ownership is passed to caller.
   * @return @b PvlGroup* The pertinent data from the Camera class on the point. 
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::SetImage(const double sample, const double line,
                                      const bool outside, const bool errors) {
                                      const bool allowOutside, const bool allowErrors) {
    if (CheckCube()) {
      bool passed = m_camera->SetImage(sample, line);
      return GetPointInfo(passed, outside, errors);
      return GetPointInfo(passed, allowOutside, allowErrors);
    }
    // Should never get here, error will be thrown in CheckCube()
    return NULL;
  }


  /**
   * SetCenter sets the image coordinates to the center of the image. 
   *  
   * @return PvlGroup* The pertinent data from the Camera class on
   *         the point. Ownership is passed to caller.
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *
   * @return @b PvlGroup* The pertinent data from the Camera class on the point. 
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::SetCenter(const bool outside, const bool errors) {
  PvlGroup *CameraPointInfo::SetCenter(const bool allowOutside, const bool allowErrors) {
    if (CheckCube()) {
      bool passed = m_camera->SetImage(m_currentCube->sampleCount() / 2.0, 
                                       m_currentCube->lineCount() / 2.0);
      return GetPointInfo(passed, outside, errors);
      return GetPointInfo(passed, allowOutside, allowErrors);
    }
    // Should never get here, error will be thrown in CheckCube()
    return NULL;
@@ -123,14 +131,20 @@ namespace Isis {
   * SetSample sets the image coordinates to the center line and the
   * given sample.
   *
   * @return PvlGroup* The pertinent data from the Camera class on
   *         the point. Ownership is passed to caller.
   * @param sample A sample coordinate in or almost in the cube.
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *  
   * @return @b PvlGroup* The pertinent data from the Camera class on the point. 
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::SetSample(const double sample,
                                       const bool outside, const bool errors) {
                                       const bool allowOutside, 
                                       const bool allowErrors) {
    if (CheckCube()) {
      bool passed = m_camera->SetImage(sample, m_currentCube->lineCount() / 2.0);
      return GetPointInfo(passed, outside, errors);
      return GetPointInfo(passed, allowOutside, allowErrors);
    }
    // Should never get here, error will be thrown in CheckCube()
    return NULL;
@@ -141,14 +155,20 @@ namespace Isis {
   * SetLine sets the image coordinates to the center sample and the
   * given line.
   *
   * @return PvlGroup* The pertinent data from the Camera class on
   *         the point. Ownership is passed to caller.
   * @param line A line coordinate in or almost in the cube.
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *  
   * @return @b PvlGroup* The pertinent data from the Camera class on the point. 
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::SetLine(const double line,
                                     const bool outside, const bool errors) {
                                     const bool allowOutside,
                                     const bool allowErrors) {
    if (CheckCube()) {
      bool passed = m_camera->SetImage(m_currentCube->sampleCount() / 2.0, line);
      return GetPointInfo(passed, outside, errors);
      return GetPointInfo(passed, allowOutside, allowErrors);
    }
    // Should never get here, error will be thrown in CheckCube()
    return NULL;
@@ -159,19 +179,20 @@ namespace Isis {
   * SetGround sets a latitude, longitude grrund coordinate in the
   * camera so data can be accessed.
   *
   * @param latitude A latitude coordinate in or almost in the
   *                 cube
   * @param longitude A longitude coordinate in or almost in the
   *                  cube
   * @param latitude A latitude coordinate in or almost in the cube
   * @param longitude A longitude coordinate in or almost in the cube
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *
   * @return PvlGroup* The pertinent data from the Camera class on
   *         the point. Ownership is passed to caller.
   * @return @b PvlGroup* The pertinent data from the Camera class on the point. 
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::SetGround(const double latitude, const double longitude,
                                       const bool outside, const bool errors) {
                                       const bool allowOutside, const bool allowErrors) {
    if (CheckCube()) {
      bool passed = m_camera->SetUniversalGround(latitude, longitude);
      return GetPointInfo(passed, outside, errors);
      return GetPointInfo(passed, allowOutside, allowErrors);
    }
    // Should never get here, error will be thrown in CheckCube()
    return NULL;
@@ -182,7 +203,7 @@ namespace Isis {
   * CheckCube checks that a cube has been set before the data for
   * a point is accessed.
   *
   * @return bool Whether or not a cube has been set, true if it has been.
   * @return @b bool Indicates whether a cube has been set.
   */
  bool CameraPointInfo::CheckCube() {
    if (m_currentCube == NULL) {
@@ -193,12 +214,19 @@ namespace Isis {
    return true;
  }


  /**
   * GetPointInfo builds the PvlGroup containing all the important
   * information derived from the Camera. 
   *  
   * @return PvlGroup* Data taken directly from the Camera and
   *         drived from Camera information. Ownership passed.
   * @param passed Indicates whether the call to SetImage() was successful.
   * @param allowOutside Indicates whether to allow extrapolation.
   * @param allowErrors  Indicates whether to allow the program to 
   *                     throw an error if a problem occurs.
   *
   * @return @b PvlGroup* Data taken directly from the Camera and 
   *                      derived from Camera information.
   *                      Ownership is passed to caller.
   */
  PvlGroup *CameraPointInfo::GetPointInfo(bool passed, bool allowOutside, bool allowErrors) {
    PvlGroup *gp = new PvlGroup("GroundPoint");
@@ -286,7 +314,6 @@ namespace Isis {
      gp->findKeyword("SunPosition").addComment("Sun Information");
      gp->findKeyword("Phase").addComment("Illumination and Other");
    }

    else {

      Brick b(3, 3, 1, m_currentCube->pixelType());
@@ -434,10 +461,21 @@ namespace Isis {
  }


  /** 
   * Retrieves a pointer to the camera.
   * 
   * @return @b Camera* A pointer to the Camera. 
   */
  Camera *CameraPointInfo::camera() {
    return m_camera;
  }


  /** 
   * Retrieves a pointer to the current cube.
   * 
   * @return @b Cube* A pointer to the current cube. 
   */
  Cube *CameraPointInfo::cube() {
    return m_currentCube;
  }
+37 −47
Original line number Diff line number Diff line
@@ -33,59 +33,49 @@ namespace Isis {


  /**
   * @brief CameraPointInfo provides quick access to the majority of
   *        information avaliable from a camera on a point.
   * @brief CameraPointInfo provides quick access to the majority of information avaliable from a 
   *        camera on a point.
   *
   * CameraPointInfo provides the functionality which was a part of
   * campt in class form. This functionality is access to the
   * majoirty of information avaliable on any given point on an
   * image. The main difference is the use of a CubeManager within
   * CameraPointInfo for effeciency when working with control nets and
   * the opening of cubes several times.
   * CameraPointInfo provides the functionality which was a part of campt in class form. This 
   * functionality is access to the majoirty of information avaliable on any given point on an
   * image. The main difference is the use of a CubeManager within CameraPointInfo for effeciency 
   * when working with control nets and the opening of cubes several times.
   *
   * @author 2009-08-25 Mackenzie Boyd
   *
   * @internal
   *   @history 2009-09-13 Mackenzie Boyd - Added methods SetCenter, SetSample 
   *                           and SetLine to support campt functionality.
   *                           Added CheckCube private method to check
   *                           m_currentCube isn't NULL.
   *   @history 2010-03-25 MNB - Modified longitude output to have Positive East
   *                           and West, 360 and 180 longitudes.
   *   @history 2010-05-25 MNB - Many changes, primary changes had to do with
   *                           how errors are handled. Depending on the options
   *                           sent in, errors can be handled by putting an
   *                           Error keyword into the PvlGroup instead of
   *                           throwing an exception. Other changes, addition of
   *                           two booleans, both defaulting to false, to the
   *                           Set methods (excluding SetCube) so that
   *                           allowoutside option and allowerrors option could
   *                           be taken in instead of using setters. 
   *                           CheckConditions method was removed and placed
   *                           within GetPointInfo, GetPointInfo had 3 boolean
   *                           parameters added, passed - whether or not the
   *                           SetImage or SetGround done above was successful,
   *                           allowoutside - if locations outside the cube are
   *                           acceptable, and allowerrors - what to do with
   *                           errors.
   *   @history 2010-06-07 MNB - Changed Error keyword so that it is always
   *                           present when allowErrors is true.
   *   @history 2010-09-13 Steven Lambright - Corrected units for
   *                           SampleResolution and LineResolution
   *   @history 2012-07-06 Debbie A. Cook - Updated Spice members to be more
   *                           compliant with Isis coding standards.
   *                           References #972.
   *   @history 2013-03-27 Jeannie Backer - Added comment in code.
   *                           References #1248.
   *   @history 2009-09-13 Mackenzie Boyd - Added methods SetCenter(), SetSample() and SetLine() to
   *                           support campt functionality. Added CheckCube() private method to
   *                           check m_currentCube isn't NULL.
   *   @history 2010-03-25 Mackenzie Boyd - Modified longitude output to have Positive East and
   *                           West, 360 and 180 longitudes.
   *   @history 2010-05-25 Mackenzie Boyd - Many changes, primary changes had to do with how errors
   *                           are handled. Depending on the options sent in, errors can be handled
   *                           by putting an Error keyword into the PvlGroup instead of throwing an
   *                           exception. Other changes, addition of two booleans, both defaulting
   *                           to false, to the Set methods (excluding SetCube) so that allowoutside
   *                           option and allowerrors option could be taken in instead of using
   *                           setters. CheckConditions method was removed and placed within
   *                           GetPointInfo, GetPointInfo had 3 boolean parameters added,
   *                           passed - whether or not the SetImage or SetGround done above was
   *                           successful, allowoutside - if locations outside the cube are
   *                           acceptable, and allowerrors - what to do with errors.
   *   @history 2010-06-07 Mackenzie Boyd - Changed Error keyword so that it is always present when
   *                           allowErrors is true.
   *   @history 2010-09-13 Steven Lambright - Corrected units for SampleResolution and
   *                           LineResolution
   *   @history 2012-07-06 Debbie A. Cook - Updated Spice members to be more compliant with Isis
   *                           coding standards. References #972.
   *   @history 2013-03-27 Jeannie Backer - Added comment in code. References #1248.
   *   @history 2012-12-20 Debbie A. Cook - Changed to use TProjection.  References #775.
   *   @history 2013-03-16 Jeannie Backer - Added accessor methods camera()
   *                           and cube(). Added m_ prefix to member variables. Made
   *                           GetPointInfo() virtual so it can be redefined in child classes.
   *                           References #775.
   *   @history 2014-04-17 Jeannie Backer - Added check for valid azimuth values.  If
   *                           not, print "NULL" to be consistent with caminfo's CamTools.cpp.
   *                           Replaced local variable names with more descriptive names.
   *                           References #1659.
   *   @history 2013-03-16 Jeannie Backer - Added accessor methods camera() and cube(). Added
   *                           m_ prefix to member variables. Made GetPointInfo() virtual so it can
   *                           be redefined in child classes. References #775.
   *   @history 2014-04-17 Jeannie Backer - Added check for valid azimuth values.  If not, print
   *                           "NULL" to be consistent with caminfo's CamTools.cpp. Replaced local
   *                           variable names with more descriptive names. References #1659.
   *   @history 2015-10-01 Jeannie Backer - Made improvements to documentation and brought code
   *                           closer to ISIS coding standards. References #1438
   */
  class CameraPointInfo {

+48 −26
Original line number Diff line number Diff line
#include "DemShape.h"

// Qt third party includes
#include <QDebug>
#include <QVector>

// c standard library third party includes
@@ -18,27 +19,48 @@

#include "Cube.h"
#include "CubeManager.h"
#include "Distance.h"
#include "EllipsoidShape.h"
//#include "Geometry3D.h"
#include "IException.h"
#include "Interpolator.h"
#include "Latitude.h"
//#include "LinearAlgebra.h"
#include "Longitude.h"
#include "NaifStatus.h"
#include "Portal.h"
#include "Projection.h"
#include "Pvl.h"
#include "Spice.h"
#include "SurfacePoint.h"
#include "Table.h"
#include "Target.h"
#include "UniqueIOCachingAlgorithm.h"

using namespace std;

namespace Isis {
  /**
   * Construct a DemShape object. This method creates a ShapeModel object named 
   * "DemShape". The member variables are set to Null. 
   *
   */
  DemShape::DemShape() : ShapeModel () {
    setName("DemShape");
    m_demProj = NULL;
    m_demCube = NULL;
    m_interp = NULL;
    m_portal = NULL;
  }


  /**
   * Construct a DemShape object. This method creates a ShapeModel object 
   * named "DemShape" and initializes member variables from the projection 
   * shape model using the given Target and Pvl. 
   *
   * @param pvl Valid Isis3 cube label.
   * @param target Pointer to a valid target.
   * @param pvl Valid ISIS cube label.
   */
  DemShape::DemShape(Target *target, Pvl &pvl) : ShapeModel (target, pvl) {
    setName("DemShape");
@@ -80,20 +102,6 @@ namespace Isis {
  }


  /**
   * Construct a DemShape object. This method creates a ShapeModel object named 
   * "DemShape". The member variables are set to Null. 
   *
   */
  DemShape::DemShape() : ShapeModel () {
    setName("DemShape");
    m_demProj = NULL;
    m_demCube = NULL;
    m_interp = NULL;
    m_portal = NULL;
  }


  //! Destroys the DemShape
  DemShape::~DemShape() {
    m_demProj = NULL;
@@ -124,15 +132,18 @@ namespace Isis {
   * @param observerPos
   * @param lookDirection
   *  
   * @return Indicates whether the intersection was found.
   * @return @b bool Indicates whether the intersection was found.
   */
  bool DemShape::intersectSurface(vector<double> observerPos,
                                  vector<double> lookDirection) {
    // try to intersect the target body ellipsoid as a first approximation
    // for the iterative DEM intersection method
    // (this method is in the ShapeModel base class) 
    if (!intersectEllipsoid(observerPos, lookDirection))
   
    bool ellipseIntersected = intersectEllipsoid(observerPos, lookDirection);
    if (!ellipseIntersected) {
      return false;
    }

    double tol = resolution()/100;  // 1/100 of a pixel
    static const int maxit = 100;
@@ -167,16 +178,16 @@ namespace Isis {

      // The lat/lon calculations are done here by hand for speed & efficiency
      // With doing it in the SurfacePoint class using p_surfacePoint, there
      //   is a 24% slowdown (which is significant in this very tightly looped
      //   call).
      // is a 24% slowdown (which is significant in this very tightly looped call).
      double t = newIntersectPt[0] * newIntersectPt[0] +
          newIntersectPt[1] * newIntersectPt[1];
      
      latDD = atan2(newIntersectPt[2], sqrt(t)) * RAD2DEG;
      lonDD = atan2(newIntersectPt[1], newIntersectPt[0]) * RAD2DEG;
       
      if (lonDD < 0)
      if (lonDD < 0) {
        lonDD += 360;
      }

      // Previous Sensor version used local version of this method with lat and lon doubles. 
      // Steven made the change to improve speed.  He said the difference was negilgible.  
@@ -196,10 +207,21 @@ namespace Isis {
      bool status;
      surfpt_c((SpiceDouble *) &observerPos[0], &lookDirection[0], r, r, r, newIntersectPt,
               (SpiceBoolean*) &status);
      setHasIntersection(status);

      if (!status)
      // LinearAlgebra::Vector point = LinearAlgebra::vector(observerPos[0], 
      //                                                     observerPos[1], 
      //                                                     observerPos[2]);
      // LinearAlgebra::Vector direction = LinearAlgebra::vector(lookDirection[0], 
      //                                                         lookDirection[1], 
      //                                                         lookDirection[2]);
      // QList<double> ellipsoidRadii;
      // ellipsoidRadii << r << r << r;
      // LinearAlgebra::Vector newPt = Geometry3D::intersect(point, direction, ellipsoidRadii);

      setHasIntersection(status);
      if (!status) {
        return status;
      }

      dX = currentIntersectPt[0] - newIntersectPt[0];
      dY = currentIntersectPt[1] - newIntersectPt[1];
@@ -231,7 +253,7 @@ namespace Isis {
   * @param lat Latitude
   * @param lon Longitude
   *  
   * @return @b double Local radius from the DEM
   * @return @b Distance Local radius from the DEM
   */
  Distance DemShape::localRadius(const Latitude &lat, const Longitude &lon) {
    
@@ -262,7 +284,7 @@ namespace Isis {
  /** 
   * Return the scale of the DEM shape, in pixels per degree.
   *  
   * @return The scale of the DEM
   * @return @b double The scale of the DEM.
   */
  double DemShape::demScale() {
    return m_pixPerDegree;
@@ -281,7 +303,7 @@ namespace Isis {
  /** 
   * Returns the DEM Cube object.
   *  
   * @return The DEM cube associated with this shape model.
   * @return @b Cube* A pointer to the DEM cube associated with this shape model.
   */
  Cube *DemShape::demCube() {
    return m_demCube;
@@ -295,7 +317,7 @@ namespace Isis {
   * implemented by all DemShape classes. This parent implementation returns 
   * true. 
   *  
   * @return bool Indicates that this is a DEM shape model. 
   * @return @b bool Indicates that this is a DEM shape model. 
   */ 
  bool DemShape::isDEM() const { 
    return true;
Loading