Unverified Commit 2996cfc4 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Continuation of updating SpicePosition to use States (#3947)



* Initial draft for feedback SpicePosition updated to use States

* Added States to SpicePosition and SpiceRotaiton. Removed p_cache and p_velocityCache

* Remove debug output and update ReloadCache to use current cache to populate new cache.

* Initial updates to SpiceRotation

* Update SpicePosition to completely use States for caching position and velocity values

* Revert SpiceRotation to dev

* Small amount of cleanup

* Updated SpicePosition based on feedback

* Update SpiceRotation

* Update based on comments

* fixed cache size

* semi-colons

* More dumb errors

* Fixed bad velocity

* Now properly passing cache reduction tolerance

* actually reducing cache now

* Properly reseting time cache after reduction

* More clean up

* More careful loading

* Testing stuff

* Compiling post merge

* Fixed test ISDs

* updates for unit tests

* Fixed cache size check

Co-authored-by: default avatarKristin <kberry@usgs.gov>
parent 46f202d4
Loading
Loading
Loading
Loading
+131 −318
Original line number Diff line number Diff line
@@ -101,12 +101,11 @@ namespace Isis {
    p_timeBias = 0.0;
    p_timeScale = 1.;
    p_velocity.resize(3);
    p_xhermite = NULL;
    p_yhermite = NULL;
    p_zhermite = NULL;


    m_swapObserverTarget = swapObserverTarget;
    m_lt = 0.0;
    m_state = NULL;

    // Determine observer/target ordering
    if ( m_swapObserverTarget ) {
@@ -245,7 +244,10 @@ namespace Isis {
    NaifStatus::CheckErrors();

    // Save the time
    if(et == p_et) return p_coordinate;
    if(et == p_et) {
      return p_coordinate;
    }

    p_et = et;

    // Read from the cache
@@ -310,13 +312,22 @@ namespace Isis {
    LoadTimeCache();

    // Loop and load the cache
    std::vector<ale::State> stateCache;
    for(int i = 0; i < size; i++) {
      double et = p_cacheTime[i];
      SetEphemerisTime(et);
      p_cache.push_back(p_coordinate);
      if(p_hasVelocity) p_cacheVelocity.push_back(p_velocity);
      ale::State currentState = ale::State(ale::Vec3d(p_coordinate));
      if (p_hasVelocity) {
        currentState.velocity = ale::Vec3d(p_velocity);
      }
      stateCache.push_back(currentState);
    }

    if (m_state != NULL) {
      delete m_state;
    }

    m_state = new ale::States(p_cacheTime, stateCache);
    p_source = Memcache;
  }

@@ -359,25 +370,31 @@ namespace Isis {
    p_fullCacheSize = isdPos["spk_table_original_size"].get<double>();
    p_cacheTime = isdPos["ephemeris_times"].get<std::vector<double>>();

    p_hasVelocity = isdPos.find("velocities") != isdPos.end();

    std::vector<ale::State> stateCache;
    if (p_hasVelocity) {
      for (auto it = isdPos["positions"].begin(); it != isdPos["positions"].end(); it++) {
        int index = it - isdPos["positions"].begin();
        std::vector<double> pos = it->get<std::vector<double>>();
        std::vector<double> vel = isdPos["velocities"][index];
        stateCache.push_back(ale::State(ale::Vec3d(pos), ale::Vec3d(vel)));
      }
    }
    else {
      for (auto it = isdPos["positions"].begin(); it != isdPos["positions"].end(); it++) {
        std::vector<double> pos = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>()};
      p_cache.push_back(pos);
        stateCache.push_back(ale::State(ale::Vec3d(pos)));
      }

    p_cacheVelocity.clear();

    bool hasVelocityKey = isdPos.find("velocities") != isdPos.end();

    if (hasVelocityKey) {
      for (auto it = isdPos["velocities"].begin(); it != isdPos["velocities"].end(); it++) {
        std::vector<double> vel = {it->at(0).get<double>(), it->at(1).get<double>(), it->at(2).get<double>()};
        p_cacheVelocity.push_back(vel);
    }

    if (m_state != NULL) {
      delete m_state;
    }

    p_hasVelocity = !p_cacheVelocity.empty();
    p_source = Memcache;
    m_state = new ale::States(p_cacheTime, stateCache);

    p_source = Memcache;
    SetEphemerisTime(p_cacheTime[0]);
  }

@@ -445,6 +462,7 @@ namespace Isis {
                       _FILEINFO_);
    }

    std::vector<ale::State> stateCache;
    // Loop through and move the table to the cache
    if (p_source != PolyFunction) {
      for (int r = 0; r < table.Records(); r++) {
@@ -460,24 +478,26 @@ namespace Isis {
          throw IException(IException::Programmer, msg, _FILEINFO_);
        }

        std::vector<double> j2000Coord;
        j2000Coord.push_back((double)rec[0]);
        j2000Coord.push_back((double)rec[1]);
        j2000Coord.push_back((double)rec[2]);
        ale::State currentState(ale::Vec3d((double)rec[0],
                                           (double)rec[1],
                                           (double)rec[2]));

        int inext = 3;

        p_cache.push_back(j2000Coord);
        if (p_hasVelocity) {
          std::vector<double> j2000Velocity;
          j2000Velocity.push_back((double)rec[3]);
          j2000Velocity.push_back((double)rec[4]);
          j2000Velocity.push_back((double)rec[5]);
          currentState.velocity = ale::Vec3d((double)rec[3],
                                             (double)rec[4],
                                             (double)rec[5]);
          inext = 6;

          p_cacheVelocity.push_back(j2000Velocity);
        }
        stateCache.push_back(currentState);
        p_cacheTime.push_back((double)rec[inext]);
      }

      if (m_state != NULL) {
        delete m_state;
      }
      m_state = new ale::States(p_cacheTime, stateCache);
    }
    else {
      // Coefficient table for postion coordinates x, y, and z
@@ -502,7 +522,7 @@ namespace Isis {
      SetOverrideBaseTime(baseTime, timeScale);
      SetPolynomial(coeffX, coeffY, coeffZ);
      if (degree > 0)  p_hasVelocity = true;
      if(degree == 0  && p_cacheVelocity.size() > 0) p_hasVelocity = true;
      if(degree == 0  && m_state->hasVelocity()) p_hasVelocity = true;
    }
  }

@@ -525,9 +545,6 @@ namespace Isis {
      LineCache(tableName);
      // TODO Figure out how to get the tolerance -- for now hard code .01
      Memcache2HermiteCache(0.01);

      //std::cout << "Cache size is " << p_cache.size();

    }

    // record to be added to table
@@ -560,28 +577,30 @@ namespace Isis {

      int inext = 0;

      for (int i = 0; i < (int)p_cache.size(); i++) {
        record[inext++] = p_cache[i][0];                     // record[0]
        record[inext++] = p_cache[i][1];                     // record[1]
        record[inext++] = p_cache[i][2];                     // record[2]
      std::vector<ale::State> stateCache = m_state->getStates();
      for (int i = 0; i < (int)stateCache.size(); i++) {
        record[inext++] = stateCache[i].position.x;          // record[0]
        record[inext++] = stateCache[i].position.y;          // record[1]
        record[inext++] = stateCache[i].position.z;          // record[2]
        if (p_hasVelocity) {
          record[inext++] = p_cacheVelocity[i][0];           // record[3]
          record[inext++] = p_cacheVelocity[i][1];           // record[4]
          record[inext++] = p_cacheVelocity[i][2];           // record[5]
          record[inext++] = stateCache[i].velocity.x;        // record[3]
          record[inext++] = stateCache[i].velocity.y;        // record[4]
          record[inext++] = stateCache[i].velocity.z;        // record[5]
        }
        record[inext] = p_cacheTime[i];                      // record[6]
        table += record;

        inext = 0;
      }

      CacheLabel(table);
      return table;
    }

    else if(p_source == PolyFunction  &&  p_degree == 0  &&  p_fullCacheSize == 1)
    else if(p_source == PolyFunction  &&  p_degree == 0  &&  p_fullCacheSize == 1){
      // Just load the position for the single epoch
      return LineCache(tableName);

    }
    // Load the coefficients for the curves fit to the 3 camera angles
    else if (p_source == PolyFunction) {
      // PolyFunction case
@@ -715,11 +734,6 @@ namespace Isis {

    // Clear existing positions from thecache
    p_cacheTime.clear();
    p_cache.clear();

    // Clear the velocity cache if we can calculate it instead.  It can't be calculated for
    // functions of degree 0 (framing cameras), so keep the original velocity.  It is better than nothing.
    if (p_degree > 0  && p_cacheVelocity.size() > 1)  p_cacheVelocity.clear();

    // Load the time cache first
    LoadTimeCache();
@@ -727,19 +741,28 @@ namespace Isis {
    if (p_fullCacheSize > 1) {
      // Load the positions and velocity caches
      p_et = -DBL_MAX;   // Forces recalculation in SetEphemerisTime

      std::vector<ale::State> stateCache;
      for (std::vector<double>::size_type pos = 0; pos < p_cacheTime.size(); pos++) {
        //        p_et = p_cacheTime.at(pos);
        SetEphemerisTime(p_cacheTime.at(pos));
        p_cache.push_back(p_coordinate);
        p_cacheVelocity.push_back(p_velocity);
        stateCache.push_back(ale::State(ale::Vec3d(p_coordinate), ale::Vec3d(p_velocity)));
      }
      if (m_state != NULL) {
        delete m_state;
      }
      m_state = new ale::States(p_cacheTime, stateCache);
    }
    else {
    // Load the position for the single updated time instance
      p_et = p_cacheTime[0];
      SetEphemerisTime(p_et);
      p_cache.push_back(p_coordinate);
      std::vector<ale::State> stateCache;
      stateCache.push_back(p_coordinate);
      std::vector<double> timeCache;
      timeCache.push_back(p_cacheTime[0]);
      if (m_state != NULL) {
        delete m_state;
      }
      m_state = new ale::States(timeCache, stateCache);
    }

    // Set source to cache and reset current et
@@ -795,8 +818,6 @@ namespace Isis {
    // Set velocity vector to true since it is calculated
    p_hasVelocity = true;

//    std::cout <<"time cache size is " << p_cacheTime.size() << std::endl;

    // Calculate new postition coordinates from polynomials fit to coordinates &
    // fill cache
//    std::cout << "Before" << std::endl;
@@ -865,6 +886,7 @@ namespace Isis {
    }

    // add positions and velocities for these times
    std::vector<ale::State> stateCache;
    for(int i = 0; i < (int) p_cacheTime.size(); i++) {
      // x,y,z positions
      double time;
@@ -872,14 +894,17 @@ namespace Isis {
      p_coordinate[0] = function1.Evaluate(time);
      p_coordinate[1] = function2.Evaluate(time);
      p_coordinate[2] = function3.Evaluate(time);
      p_cache.push_back(p_coordinate);

      // x,y,z velocities
      p_velocity[0] = b1 + 2 * c1 * (p_cacheTime[i] - p_baseTime);
      p_velocity[1] = b2 + 2 * c2 * (p_cacheTime[i] - p_baseTime);
      p_velocity[2] = b3 + 2 * c3 * (p_cacheTime[i] - p_baseTime);
      p_cacheVelocity.push_back(p_velocity);
      stateCache.push_back(ale::State(p_coordinate, p_velocity));
    }
    if (m_state != NULL) {
      delete m_state;
    }
    m_state = new ale::States(p_cacheTime, stateCache);

    p_source = HermiteCache;
    double et = p_et;
@@ -904,10 +929,11 @@ namespace Isis {
      return;

    // Adjust the degree of the polynomial to the available data
    if (p_cache.size() == 1) {
    int size = m_state->getStates().size();
    if (size == 1) {
      p_degree = 0;
    }
    else if (p_cache.size() == 2) {
    else if (size == 2) {
      p_degree = 1;
    }

@@ -928,14 +954,14 @@ namespace Isis {
    ComputeBaseTime();
    std::vector<double> time;

    if(p_cache.size() == 1) {
    if(size == 1) {
      double t = p_cacheTime.at(0);
      SetEphemerisTime(t);
      XC.push_back(p_coordinate[0]);
      YC.push_back(p_coordinate[1]);
      ZC.push_back(p_coordinate[2]);
    }
    else if(p_cache.size() == 2) {
    else if(size == 2) {
      // Load the times and get the corresponding coordinates
      double t1 = p_cacheTime.at(0);
      SetEphemerisTime(t1);
@@ -1260,56 +1286,23 @@ namespace Isis {
   *            method)
   */
  void SpicePosition::SetEphemerisTimeMemcache() {
    // If the cache has only one position return it
    if(p_cache.size() == 1) {
      p_coordinate[0] = p_cache[0][0];
      p_coordinate[1] = p_cache[0][1];
      p_coordinate[2] = p_cache[0][2];
      if(p_hasVelocity) {
        p_velocity[0] = p_cacheVelocity[0][0];
        p_velocity[1] = p_cacheVelocity[0][1];
        p_velocity[2] = p_cacheVelocity[0][2];
      }
    ale::State state;
    if (p_cacheTime.size() == 1) {
      state = m_state->getStates().front();
    }

    else {
      // Otherwise determine the interval to interpolate
      std::vector<double>::iterator pos;
      pos = upper_bound(p_cacheTime.begin(), p_cacheTime.end(), p_et);

      int cacheIndex;
      if(pos != p_cacheTime.end()) {
        cacheIndex = distance(p_cacheTime.begin(), pos);
        cacheIndex--;
      state = m_state->getState(p_et, ale::LINEAR);
    }
      else {
        cacheIndex = p_cacheTime.size() - 2;
      }

      if(cacheIndex < 0) cacheIndex = 0;

      // Interpolate the coordinate
      double mult = (p_et - p_cacheTime[cacheIndex]) /
                    (p_cacheTime[cacheIndex+1] - p_cacheTime[cacheIndex]);
      std::vector<double> p2 = p_cache[cacheIndex+1];
      std::vector<double> p1 = p_cache[cacheIndex];

      p_coordinate[0] = (p2[0] - p1[0]) * mult + p1[0];
      p_coordinate[1] = (p2[1] - p1[1]) * mult + p1[1];
      p_coordinate[2] = (p2[2] - p1[2]) * mult + p1[2];

    p_coordinate[0] = state.position.x;
    p_coordinate[1] = state.position.y;
    p_coordinate[2] = state.position.z;
    if (p_hasVelocity){
        p2 = p_cacheVelocity[cacheIndex+1];
        p1 = p_cacheVelocity[cacheIndex];
        p_velocity[0] = (p2[0] - p1[0]) * mult + p1[0];
        p_velocity[1] = (p2[1] - p1[1]) * mult + p1[1];
        p_velocity[2] = (p2[2] - p1[2]) * mult + p1[2];
      p_velocity[0] = state.velocity.x;
      p_velocity[1] = state.velocity.y;
      p_velocity[2] = state.velocity.z;
    }
  }

  }



  /**
   * This is a protected method that is called by
@@ -1323,78 +1316,21 @@ namespace Isis {
   *   @history 2009-08-03 Jeannie Walldren - Original version
   */
  void SpicePosition::SetEphemerisTimeHermiteCache() {
    if (p_hasVelocity) {
      ale::State state = m_state->getState(p_et, ale::SPLINE);

    // what if framing camera???

    // On the first SetEphemerisTime, create our splines. Later calls should
    // reuse these splines.
    if(p_xhermite == NULL) {
      p_overrideTimeScale = 1.;
      p_override = ScaleOnly;
      ComputeBaseTime();
      p_coordinate[0] = state.position.x;
      p_coordinate[1] = state.position.y;
      p_coordinate[2] = state.position.z;

      p_xhermite = new NumericalApproximation(
          NumericalApproximation::CubicHermite);
      p_yhermite = new NumericalApproximation(
          NumericalApproximation::CubicHermite);
      p_zhermite = new NumericalApproximation(
          NumericalApproximation::CubicHermite);

      vector<double> xvalues(p_cache.size());
      vector<double> xhermiteYValues(p_cache.size());
      vector<double> yhermiteYValues(p_cache.size());
      vector<double> zhermiteYValues(p_cache.size());

      vector<double> xhermiteVelocities(p_cache.size());
      vector<double> yhermiteVelocities(p_cache.size());
      vector<double> zhermiteVelocities(p_cache.size());

      for(unsigned int i = 0; i < p_cache.size(); i++) {
        vector<double> &cache = p_cache[i];
        double &cacheTime = p_cacheTime[i];
        xvalues[i] = (cacheTime - p_baseTime) / p_timeScale;

        xhermiteYValues[i] = cache[0];
        yhermiteYValues[i] = cache[1];
        zhermiteYValues[i] = cache[2];

        if(p_hasVelocity) {  // Line scan camera
          vector<double> &cacheVelocity = p_cacheVelocity[i];
          xhermiteVelocities[i] = cacheVelocity[0];
          yhermiteVelocities[i] = cacheVelocity[1];
          zhermiteVelocities[i] = cacheVelocity[2];
        }
        else { // Not line scan camera
          throw IException(IException::Io, "No velocities available.",
                           _FILEINFO_);
        }
      p_velocity[0] = state.velocity.x;
      p_velocity[1] = state.velocity.y;
      p_velocity[2] = state.velocity.z;
    }

      p_xhermite->AddData(xvalues, xhermiteYValues);
      p_xhermite->AddCubicHermiteDeriv(xhermiteVelocities);

      p_yhermite->AddData(xvalues, yhermiteYValues);
      p_yhermite->AddCubicHermiteDeriv(yhermiteVelocities);

      p_zhermite->AddData(xvalues, zhermiteYValues);
      p_zhermite->AddCubicHermiteDeriv(zhermiteVelocities);
    else {
      throw IException(IException::Io, "No velocities available. Cannot calculate Hermite Cache.",
                       _FILEINFO_);
    }

    // Next line added 07/13/2009 to prevent Camera unit test from bombing
    // because time is outside domain. DAC Also added etype to Evaluate calls
    NumericalApproximation::ExtrapType etype =
        NumericalApproximation::Extrapolate;

    vector<double> &coordinate = p_coordinate;
    double sTime = (p_et - p_baseTime) / p_timeScale;
    coordinate[0] = p_xhermite->Evaluate(sTime, etype);
    coordinate[1] = p_yhermite->Evaluate(sTime, etype);
    coordinate[2] = p_zhermite->Evaluate(sTime, etype);

    vector<double> &velocity = p_velocity;
    velocity[0] = p_xhermite->EvaluateCubicHermiteFirstDeriv(sTime);
    velocity[1] = p_yhermite->EvaluateCubicHermiteFirstDeriv(sTime);
    velocity[2] = p_zhermite->EvaluateCubicHermiteFirstDeriv(sTime);
  }


@@ -1433,17 +1369,16 @@ namespace Isis {
    if(p_hasVelocity) {

      if( p_degree == 0) {
        p_velocity = p_cacheVelocity[0];
        ale::Vec3d velocity = m_state->getVelocities()[0];
        p_velocity[0] = velocity.x;
        p_velocity[1] = velocity.y;
        p_velocity[2] = velocity.z;
      }
      else {
        p_velocity[0] = ComputeVelocityInTime(WRT_X);
        p_velocity[1] = ComputeVelocityInTime(WRT_Y);
        p_velocity[2] = ComputeVelocityInTime(WRT_Z);
      }

//         p_velocity[0] = functionX.DerivativeVar(rtime);
//         p_velocity[1] = functionY.DerivativeVar(rtime);
//         p_velocity[2] = functionZ.DerivativeVar(rtime);
    }
  }

@@ -1463,8 +1398,6 @@ namespace Isis {
    SetEphemerisTimeHermiteCache();
    std::vector<double> hermiteCoordinate = p_coordinate;

//    std::cout << hermiteCoordinate << std::endl;

    std::vector<double> hermiteVelocity = p_velocity;
    SetEphemerisTimePolyFunction();

@@ -1531,148 +1464,27 @@ namespace Isis {
                       _FILEINFO_);
    }

    // make sure base time is set before it is needed
    p_overrideTimeScale = 1.;
    p_override = ScaleOnly;
    ComputeBaseTime();

    // find current size of cache
    int n = p_cacheTime.size() - 1;

    // create 3 starting values for the new table
    vector <int> inputIndices;
    inputIndices.push_back(0);
    inputIndices.push_back(n / 2);
    inputIndices.push_back(n);

    // find all indices needed to make a hermite table within the appropriate tolerance
    vector <int> indexList = HermiteIndices(tolerance, inputIndices);

    // remove all lines from cache vectors that are not in the index list????
    for(int i = n; i >= 0; i--) {
      if(!binary_search(indexList.begin(), indexList.end(), i)) {
        p_cache.erase(p_cache.begin() + i);
        p_cacheTime.erase(p_cacheTime.begin() + i);
        p_cacheVelocity.erase(p_cacheVelocity.begin() + i);
      }
    }

    ale::States *tempStates = new ale::States(m_state->minimizeCache(tolerance));
    delete m_state;
    m_state = tempStates;
    p_cacheTime = m_state->getTimes();
    p_source = HermiteCache;
  }

  /**
   * This method is called by Memcache2HermiteCache() to determine
   * which indices from the orginal cache should be saved in the
   * reduced cache. It is a recursive method that starts with an
   * index list of 3 elements (first, center and last index
   * values) and adds values to this list if the tolerance is not
   * met.
   *
   * @param tolerance Maximum error allowed between NAIF kernel
   *                  coordinate values and values interpolated by
   *                  the Hermite spline.
   * @param indexList Vector containing the list of indices to be
   *                  kept in the cache.  This list grows as the
   *                  method is recursively called
   * @return <b>vector/<double/></b> Vector containing final list
   *         of indices that will be kept for the Hermite cache.
   * @internal
   *   @history 2009-08-03 Jeannie Walldren - Original version.
   *   @history 2009-08-14 Debbie A. Cook - Corrected indexing
   *            error in loop.
   */
  std::vector<int> SpicePosition::HermiteIndices(double tolerance, std::vector <int> indexList) {

    unsigned int n = indexList.size();
    double sTime;

    NumericalApproximation xhermite(NumericalApproximation::CubicHermite);
    NumericalApproximation yhermite(NumericalApproximation::CubicHermite);
    NumericalApproximation zhermite(NumericalApproximation::CubicHermite);
    for(unsigned int i = 0; i < indexList.size(); i++) {
      sTime = (p_cacheTime[indexList[i]] - p_baseTime) / p_timeScale;
      xhermite.AddData(sTime, p_cache[indexList[i]][0]);  // add time, x-position to x spline
      yhermite.AddData(sTime, p_cache[indexList[i]][1]);  // add time, y-position to y spline
      zhermite.AddData(sTime, p_cache[indexList[i]][2]);  // add time, z-position to z spline

      if(p_hasVelocity) {  // Line scan camera
        xhermite.AddCubicHermiteDeriv(p_cacheVelocity[i][0]); // add x-velocity to x spline
        yhermite.AddCubicHermiteDeriv(p_cacheVelocity[i][1]); // add y-velocity to y spline
        zhermite.AddCubicHermiteDeriv(p_cacheVelocity[i][2]); // add z-velocity to z spline
      }
      else { // Not line scan camera
        throw IException(IException::Io, "No velocities available.", _FILEINFO_);
        // xhermite.AddCubicHermiteDeriv(0.0); // spacecraft didn't move => velocity = 0
        // yhermite.AddCubicHermiteDeriv(0.0); // spacecraft didn't move => velocity = 0
        // zhermite.AddCubicHermiteDeriv(0.0); // spacecraft didn't move => velocity = 0
      }
    }

    // loop through the saved indices from the end
    for(unsigned int i = indexList.size() - 1; i > 0; i--) {
      double xerror = 0;
      double yerror = 0;
      double zerror = 0;

      // check every value of the original kernel values within interval
      for(int line = indexList[i-1] + 1; line < indexList[i]; line++) {
        sTime = (p_cacheTime[line] - p_baseTime) / p_timeScale;

        // find the errors at each value
        xerror = fabs(xhermite.Evaluate(sTime) - p_cache[line][0]);
        yerror = fabs(yhermite.Evaluate(sTime) - p_cache[line][1]);
        zerror = fabs(zhermite.Evaluate(sTime) - p_cache[line][2]);

        if(xerror > tolerance || yerror > tolerance || zerror > tolerance) {
          // if any error is greater than tolerance, no need to continue looking, break
          break;
        }
      }

      if(xerror < tolerance && yerror < tolerance && zerror < tolerance) {
        // if errors are less than tolerance after looping interval, no new point is necessary
        continue;
      }
      else {
        // if any error is greater than tolerance, add midpoint of interval to indexList vector
        indexList.push_back((indexList[i] + indexList[i-1]) / 2);
      }
    }

    if(indexList.size() > n) {
      sort(indexList.begin(), indexList.end());
      indexList = HermiteIndices(tolerance, indexList);
    }
    return indexList;
  }


  /**
   * Removes the entire cache from memory.
   */
  void SpicePosition::ClearCache() {
    p_cache.clear();
    p_cacheVelocity.clear();
    p_cacheTime.clear();

    if(p_xhermite) {
      delete p_xhermite;
      p_xhermite = NULL;
    }

    if(p_yhermite) {
      delete p_xhermite;
      p_xhermite = NULL;
    if (m_state) {
      delete m_state;
      m_state = NULL;
    }

    if(p_zhermite) {
      delete p_xhermite;
      p_xhermite = NULL;
    }
    p_cacheTime.clear();
  }



  /** Set the degree of the polynomials to be fit to the
   * three position coordinates for the time period covered by the
   * cache, coordinate = c0 + c1*t + c2*t**2 + ... + cn*t**n,
@@ -1759,6 +1571,7 @@ namespace Isis {
      double et = p_fullCacheStartTime + (double) i * cacheSlope;
      p_cacheTime.push_back(et);
    }

  }

  /** Compute and return the coordinate at the center time
+11 −13

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ commands:
	  update=yes \
	  cksolvedegree=3 \
	  camsolve=all \
	  bundleout_txt=no \
	  bundleout_txt=yes \
	  twist=no > /dev/null;
	# The above command uses sed to do the following (in order):
	# 1. remove cube filename paths
+1 −2
Original line number Diff line number Diff line
@@ -193,8 +193,7 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) {
      "spk_table_end_time": 100.1,
      "spk_table_original_size": 2,
      "ephemeris_times": [
        100,
        100.1
        100
      ],
      "positions": [
        [0, 20, 0]
+19 −21
Original line number Diff line number Diff line
@@ -93,8 +93,7 @@ class ConstVelIsd : public ::testing::Test {
      "spk_table_end_time": 100.1,
      "spk_table_original_size": 2,
      "ephemeris_times": [
        100,
        100.1
        100
      ],
      "positions": [
        [0, 20, 0]
@@ -191,4 +190,3 @@ TEST_F(ConstVelIsd, SunToBodyDist) {
  Spice testSpice(isisLabel, constVelIsdStr);
  EXPECT_DOUBLE_EQ(testSpice.sunToBodyDist(), 20);
}