Commit f97e30bf authored by Kristin Berry's avatar Kristin Berry
Browse files

Updated ControlNetStatistics to throw an error when output files cannot be...

Updated ControlNetStatistics to throw an error when output files cannot be opened or successfully written to. Fixes #996

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6262 41f8697f-d340-4b68-9986-7bafba869bb8
parent 36298687
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -630,6 +630,9 @@
     </change>
    <change name="Sharmila Prasad" date="2011-12-29">Updated GoodnessOfFit 
     Filter and added ControlNet stats for ControlMeasureLogData. Fixes Mantis #652 
    </change>
    <change name="Kristin Berry" date="2015-06-04">Updated ControlNetStatistics to throw 
     errors when output files cannot be opened or successfully written to. Fixes #996.
   </change>
    </history>
      
+22 −0
Original line number Diff line number Diff line
@@ -329,6 +329,11 @@ namespace Isis {
    QString outName(outFile.expanded());
    ostm.open(outName.toAscii().data(), std::ios::out);

    if ( ostm.fail() ) {
      QString msg = QObject::tr("Cannot open file [%1]").arg(psImageFile);
      throw IException(IException::Io, msg, _FILEINFO_);
     }

    //map< QString, vector<double> >::iterator it;
    map<QString, bool>::iterator it;
    // imgSamples, imgLines, imgTotalPoints, imgIgnoredPoints, imgFixedPoints, imgLockedPoints, imgLocked, imgConstrainedPoints, imgFreePoints, imgConvexHullArea, imgConvexHullRatio
@@ -350,6 +355,11 @@ namespace Isis {
          ostm << "0, 0, 0, 0, 0, 0, 0" << endl;
        }
    }

    if (!ostm) {
      QString msg = QObject::tr("Error writing to file: [%1]").arg(psImageFile);
      throw IException(IException::Io, msg, _FILEINFO_);
    }
    ostm.close(); 
  }

@@ -383,6 +393,12 @@ namespace Isis {
    ofstream ostm;
    QString outName(outFile.expanded());
    ostm.open(outName.toAscii().data(), std::ios::out);

    if ( ostm.fail() ) {
      QString msg = QObject::tr("Cannot open file [%1]").arg(psPointFile);
      throw IException(IException::Io, msg, _FILEINFO_);
    }

    ostm << " PointId, PointType, PointIgnore, PointEditLock, TotalMeasures, MeasuresValid, MeasuresIgnore, MeasuresEditLock," << endl;

    int iNumPoints = mCNet->GetNumPoints();
@@ -409,6 +425,12 @@ namespace Isis {
      if (mProgress != NULL)
        mProgress->CheckStatus();
    }

    if (!ostm) {
      QString msg = QObject::tr("Error writing to file: [%1]").arg(psPointFile);
      throw IException(IException::Io, msg, _FILEINFO_);
    }

    ostm.close();
  }

+5 −0
Original line number Diff line number Diff line
@@ -70,6 +70,11 @@ namespace Isis {
   *                           computation. Minor refactoring but needs a lot more. References #619
   *                           because fixing the order of the cnet caused us to fix some cnet graph
   *                           node bugs which caused the convex hull tests to fail.
   *  @history 2015-06-04 Kristin Berry - Now throws an error when
   *                           unable to open an output file or
   *                           finish writing to an output file.
   *                           Fixes #996.
   *  
   */
  class ControlNetStatistics {
    public: