Commit f6e93bd3 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

updated ControlNet unit test for new adjacency method

parent 27b8c493
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -866,21 +866,20 @@ namespace Isis {
   * @param serialNumber the serial number of the image to find images adjacent to.
   *
   * @returns @b QList<QString> The serial numbers of all adjacent images.
   *
   * @TODO Replace this with updated graph functionality once boost graph is in.
   */
  QList< QString > ControlNet::getAdjacentImages(QString serialNumber) const {
    if (!cubeGraphNodes->contains(serialNumber)) {
    if (!ValidateSerialNumber(serialNumber)) {
      QString msg = "Cube Serial Number [" + serialNumber + "] not found in "
          "the network";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    const ControlCubeGraphNode *queryNode = getGraphNode(serialNumber);
    QList< ControlCubeGraphNode * > adjacentNodes = queryNode->getAdjacentNodes();
    QList< QString > adjacentSerials;
    foreach(ControlCubeGraphNode * adjacentNode, adjacentNodes) {
      adjacentSerials.append(adjacentNode->getSerialNumber());

    AdjacencyIterator adjIt, adjEnd;
    boost::tie(adjIt, adjEnd) = boost::adjacent_vertices(m_vertexMap[serialNumber], m_controlGraph);
    for( ; adjIt != adjEnd; adjIt++) {
      adjacentSerials.append(m_controlGraph[*adjIt].serial);
    }

    return adjacentSerials;
+7 −8
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ namespace Isis {
  class Camera;
  class ControlMeasure;
  class ControlPoint;
  class ControlCubeGraphNode;
  class Distance;
  class Progress;
  class Pvl;
@@ -242,10 +241,6 @@ namespace Isis {

    public:

      QList< ControlCubeGraphNode * > GetCubeGraphNodes() {
        QList<ControlCubeGraphNode *> lst;
        return lst;} ; // TEMPORARY DELETE

      ControlNet();
      ControlNet(const ControlNet &other);
      ControlNet(const QString &filename, Progress *progress = 0);
@@ -378,8 +373,6 @@ namespace Isis {
      //! hash ControlPoints by ControlPoint Id
      QHash< QString, ControlPoint * > * points;

      //! hash ControlCubeGraphNodes by CubeSerialNumber

      // structs and typedefs for the boost graph
      struct Image {
        QString serial;
@@ -390,12 +383,18 @@ namespace Isis {
        int strength = 0;
      };

      typedef boost::adjacency_list<boost::setS, boost::listS, boost::undirectedS, Image, Connection> Network;
      typedef boost::adjacency_list<boost::setS,
                                    boost::listS,
                                    boost::undirectedS,
                                    Image,
                                    Connection> Network;
      typedef Network::vertex_descriptor ImageVertex;
      typedef Network::edge_descriptor ImageConnection;
      typedef std::map<ImageVertex, size_t> VertexIndexMap;
      typedef boost::associative_property_map<VertexIndexMap> VertexIndexMapAdaptor;
      typedef Network::out_edge_iterator ConnectionIterator;
      typedef boost::graph_traits<Network>::adjacency_iterator AdjacencyIterator;

      QHash<QString, ImageVertex> m_vertexMap; //!< The SN -> vertex hash for the boost graph
      Network m_controlGraph; //!< The boost graph
      QStringList *pointIds;
+20 −14
Original line number Diff line number Diff line
@@ -8,33 +8,39 @@ ALPHA [p0] --------- BRAVO [p0]
ALPHA [p0] --------- BRAVO [p0]

testing measure addition to point already in network...
ALPHA [p1, p0] --------- BRAVO [p0]
ALPHA [p0, p1] --------- BRAVO [p0]

ALPHA [p1, p0] --------- BRAVO [p1, p0]
ALPHA [p0, p1] --------- BRAVO [p0, p1]

ALPHA [p1, p0] --------- BRAVO [p1, p0]
CHARLIE [p1] --------- ALPHA [p1, p0]
CHARLIE [p1] --------- BRAVO [p1, p0]
ALPHA [p0, p1] --------- BRAVO [p0, p1]
CHARLIE [p1] --------- ALPHA [p0, p1]
CHARLIE [p1] --------- BRAVO [p0, p1]

testing setting point to ignored.......................
ALPHA [p1, p0] --------- BRAVO [p1, p0]
ALPHA [p0, p1] --------- BRAVO [p0, p1]

ALPHA [p1, p0] --------- BRAVO [p1, p0]
ALPHA [p1, p0] --------- CHARLIE [p1]
CHARLIE [p1] --------- BRAVO [p1, p0]
ALPHA [p0, p1] --------- BRAVO [p0, p1]
ALPHA [p0, p1] --------- CHARLIE [p1]
CHARLIE [p1] --------- BRAVO [p0, p1]

testing measure deletion & addition....................
ALPHA [p1, p0] --------- BRAVO [p1]
ALPHA [p1, p0] --------- CHARLIE [p1]
ALPHA [p0, p1] --------- BRAVO [p1]
ALPHA [p0, p1] --------- CHARLIE [p1]
CHARLIE [p1] --------- BRAVO [p1]

ALPHA [p1, p0] --------- BRAVO [p1]
ALPHA [p1, p0] --------- CHARLIE [p1]
ALPHA [p0, p1] --------- BRAVO [p1]
ALPHA [p0, p1] --------- CHARLIE [p1]
CHARLIE [p1] --------- BRAVO [p1]
DELTA [p0] --------- ALPHA [p1, p0]
DELTA [p0] --------- ALPHA [p0, p1]

testing FindClosest....................
Closest Point ID: p1

testing getAdjacentImages....................
Adjacent Images: 
  BRAVO
  CHARLIE
  DELTA
testing point deletion.................................
DELTA [p0] --------- ALPHA [p0]

+25 −9
Original line number Diff line number Diff line
@@ -5,9 +5,11 @@
#include <sstream>
#include <ctime>

#include <QHash>
#include <QList>
#include <QSet>
#include <QString>
#include <QStringList>
#include <QVector>

#include "ControlMeasure.h"
@@ -160,6 +162,9 @@ cout << " " << "Island Count = " << islands.size() << endl;
int main() {
  qsrand(42);

  // Set the global hash seed to ensure consistent vertex and edge ordering
  qSetGlobalQHashSeed(2255);

  Preference::Preferences(true);
  cout << "UnitTest for ControlNet ...." << endl << endl;

@@ -223,7 +228,18 @@ int main() {
  p0m0->SetCoordinate(1.0, 2.0);

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

  // test getAdjacentImages()
  cout << "testing getAdjacentImages....................\n";

  QStringList adjacentSerials = net.getAdjacentImages("ALPHA");
  // We cannot gaurantee order on this list, so sort it for testing purposes
  adjacentSerials.sort();
  cout << "Adjacent Images: " << endl;
  foreach(QString serial, adjacentSerials) {
    cout << "  " << serial << endl;
  }

  // test point deletion
  cout << "testing point deletion.................................\n";