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

Clean up and addition of tests to the unit test

parent 66607778
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -174,6 +174,10 @@ namespace Isis {
   *   @history 2018-01-05 Adam Goins - Added HasDateTime() and HasChooserName() methods to allow
   *                           to allow the value of these variables to be read without being
   *                           overriden if they're empty. (Getters override if they're empty).
   *   @history 2018-01-26 Kristin Berry - Removed code related to now-unused ControlCubeGraphNode,
   *                           as part of the switch to using the boost graph library.
   *                           References #5434
   *                           
   */
  class ControlMeasure : public QObject {

+5 −15
Original line number Diff line number Diff line
@@ -36,9 +36,7 @@ int main() {
  ControlMeasure m;
  qDebug() << "Test 1 Default values";
  m.SetChooserName("ManuallySet");
  qDebug() << "Set Chooser Name" ; 
  m.SetDateTime("2001-01-01T00:00:00");
  qDebug() << "Set DateTime" ; 
  outit(m);

  m.SetCubeSerialNumber("Test");
@@ -54,33 +52,33 @@ int main() {
  m.SetChooserName("Bob");
  m.SetDateTime("2005-05-03T00:00:00");
  qDebug() << "Test 2";
  //  outit(m);
  outit(m);

  m.SetType(ControlMeasure::Candidate);
  m.SetChooserName("Bob");
  m.SetDateTime("2005-05-03T00:00:00");
  qDebug() << "Test 3";
  //  outit(m);
  outit(m);

  m.SetType(ControlMeasure::Manual);
  m.SetChooserName("Bob");
  m.SetDateTime("2005-05-03T00:00:00");
  m.SetEditLock(true);
  qDebug() << "Test 4";
  //   outit(m);
  outit(m);

  m.SetType(ControlMeasure::RegisteredPixel);
  m.SetChooserName("Bob");
  m.SetDateTime("2005-05-03T00:00:00");
  m.SetEditLock(false);
  qDebug() << "Test 5";
  //  outit(m);
  outit(m);

  m.SetType(ControlMeasure::RegisteredSubPixel);
  m.SetChooserName("Bob");
  m.SetDateTime("2005-05-03T00:00:00");
  qDebug() << "Test 6";
  //  outit(m);
  outit(m);

  m.SetLogData(ControlMeasureLogData(ControlMeasureLogData::GoodnessOfFit, 5.0));
  m.SetChooserName("Bob");
@@ -188,21 +186,13 @@ int main() {
}

void outit(ControlMeasure &m) {
  qDebug() << "In outit";
  ControlNet net;
  qDebug() << "made the net";
  ControlPoint *pt = new ControlPoint;
  qDebug() << "made the point";
  pt->Add(new ControlMeasure(m));
  qDebug() << "added the measure";
  pt->SetId("CP01");
    qDebug() << "added the measure";
  pt->SetChooserName("Me");
    qDebug() << "added the measure";
  pt->SetDateTime("Yesterday");
    qDebug() << "added the measure";
  net.AddPoint(pt);
  qDebug() << "added the point";
  net.SetNetworkId("Identifier");
  net.SetCreatedDate("Yesterday");
  net.SetModifiedDate("Yesterday");
+24 −14
Original line number Diff line number Diff line
@@ -397,28 +397,38 @@ namespace Isis {
   * @returns A string representation of the ControlNet graph
   */
  QString ControlNet::GraphToString() const {
    // Iterate through the vertices and print them out
    /*QList<QList<QString>> serialConnections = GetSerialConnections();

    // Checking to make sure we match...    
    QList<QString> keys = m_vertexMap.keys();
    for (int i=0; i< keys.size(); i++) {
      std::cout << keys[i] << " = " << m_controlGraph[m_vertexMap[keys[i]]].serial << std::endl; 
    for (int i=0; i < serialConnections.size(); i++) {
        std::cout << "\n\n" << std::endl; 
      for (int j=0; j< serialConnections[i].size(); j++) {
        std::cout << serialConnections[i][j] << std::endl; 
      }
    }*/

    QString graphString; 
    /*QString graphString; 
    typedef boost::graph_traits<Network>::vertex_iterator vertex_iter;
    std::pair<vertex_iter, vertex_iter> vp;
    for(vp = vertices(m_controlGraph); vp.first != vp.second; ++vp.first) {
      std::cout << "serial: " << m_controlGraph[*vp.first].serial << std::endl;
      std::cout << "assoc. measure list: " << m_controlGraph[*vp.first].measures.size() << std::endl;
      std::cout << m_controlGraph[*vp.first].serial << " : \n" << std::endl;
      QHash<ControlPoint*, ControlMeasure*> measures = m_controlGraph[*vp.first].measures;
      QList<ControlPoint*> keys = measures.keys();
      for (int i=0; i < keys.size(); i++) {
        std::cout << "     " << measures[keys[i]]->GetCubeSerialNumber() << " : " << keys[i]->GetId() << std::endl; 
      }
    }*/

    typedef boost::graph_traits<Network>::edge_iterator edge_iter;
    std::pair<edge_iter, edge_iter> ep;
    edge_iter ei, ei_end;
    for (tie(ei, ei_end) = edges(m_controlGraph); ei != ei_end; ++ei)
      std::cout << "strength: " << m_controlGraph[*ei].strength << endl;
    for (tie(ei, ei_end) = edges(m_controlGraph); ei != ei_end; ++ei) {
      ImageVertex sourceImage = source(*ei, m_controlGraph);
      ImageVertex targetImage = target(*ei, m_controlGraph);
      if (sourceImage != targetImage) {
        std::cout << m_controlGraph[sourceImage].serial << " [" << m_controlGraph[sourceImage].measures.size() << "] " << "---------" << m_controlGraph[targetImage].serial << " [" << m_controlGraph[targetImage].measures.size() << "] strength: " << " [" << m_controlGraph[*ei].strength << "]" << std::endl;
      }
    }

    QString graphString; 
    return graphString;
   }

+4 −1
Original line number Diff line number Diff line
@@ -221,7 +221,10 @@ namespace Isis {
   *                           adds to the control network.
   *   @history 2018-01-26 Kristin Berry - Removed unused methods and associated code:
   *                           MinimumSpanningTree(), GetNodeConnections(), RandomBFS(), Shuffle(),
   *                           CalcBWAndCE(), CubeGraphToString(), getGraphNode()
   *                           CalcBWAndCE(), CubeGraphToString(), getGraphNode(). References #5434
   *  @history 2018-01-26 Kristin Berry - Updated to use the boost graph library instead of our
   *                           custom graph structure ControlCubeGraphNode. 
   *                           
   *                           
   */
  class ControlNet : public QObject {
+9 −10
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
#include <QString>
#include <QVector>

#include "ControlCubeGraphNode.h"
#include "ControlMeasure.h"
#include "ControlMeasureLogData.h"
#include "ControlNet.h"
@@ -287,6 +286,14 @@ int main() {
  p0->Add(p0m0);
  cout << net.GraphToString() << "\n";
  
  // test FindClosest()
  cout << "testing FindClosest....................\n";
  p1m0->SetCoordinate(1.0, 1.0);
  p0m0->SetCoordinate(1.0, 2.0);

  ControlPoint *closestPoint = net.FindClosest("ALPHA", 1.0,1.0);
  cout << "Closest Point ID: " << closestPoint->GetId() << endl; 

  // test point deletion
  cout << "testing point deletion.................................\n";
  net.DeletePoint(p1);
@@ -548,8 +555,6 @@ int main() {
  remove("temp.bin");
  remove("temp2.bin");

  cout << "Testing GetCubeGraphNodes\n";

/*  QList< ControlCubeGraphNode * > graphnodes = net.GetCubeGraphNodes();
  // Use this to sort the output
  QList<QString> sortedSNs;
@@ -561,9 +566,6 @@ int main() {
    cout << "    " << sn << "\n";
  }*/

  cout << "\nTesting getGraphNode: ";
//       << net.getGraphNode("ALPHA")->getSerialNumber() << "\n";

  cout << "\nTesting getEdgeCount: " << net.getEdgeCount() << "\n";

  testConnectivity();
@@ -582,9 +584,6 @@ int main() {
  cout << "And zero pointIDs in the original control net. There are: "
       << QString::number(net.GetPointIds().length()) << endl;

  cout << "And zero cubeGraphNodes in the original control net. There are: ";
//       << QString::number(net.GetCubeGraphNodes().length()) << endl;

    //system("cat unitTest.output | grep -v DateTime > temp.output; mv temp.output unitTest.output");
  //system("cat unitTest.output | sed -r s/`date +%Y-%m-%dT`\\[0-9:\\]\\{8\\}/2010-08-27T17:10:06/g > temp.output; mv temp.output unitTest.output");