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

Merge pull request #193 from kberryUSGS/ipceCnetHealth

Replace the ControlCubeGraphNode ControlNet graph with the boost graph library. Fixes #5434
parents 6d76af01 0342772a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ namespace Isis {
      throw IException(IException::User, msg, _FILEINFO_);
    }

    measure->associatedCSN = this;
//    measure->associatedCSN = this;
    ASSERT(!measures->contains(measure->Parent()));
    (*measures)[measure->Parent()] = measure;
  }
@@ -102,7 +102,7 @@ namespace Isis {
      ASSERT(0);
    }

    measure->associatedCSN = NULL;
//    measure->associatedCSN = NULL;
  }


+0 −6
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@
#include "ControlMeasureLogData.h"
#include "ControlNet.h"
#include "ControlPoint.h"
#include "ControlCubeGraphNode.h"
#include "IString.h"
#include "iTime.h"
#include "SpecialPixel.h"
@@ -84,13 +83,11 @@ namespace Isis {
    p_sampleResidual = other.p_sampleResidual;
    p_lineResidual = other.p_lineResidual;
    p_camera = other.p_camera;
    associatedCSN = other.associatedCSN;
  }


  //! initialize pointers and other data to NULL
  void ControlMeasure::InitializeToNull() {

    // Previously these were initialized to 0.0 in the constructor.
    p_sample = Null;
    p_line = Null;
@@ -117,7 +114,6 @@ namespace Isis {
    p_measuredEphemerisTime = Null;

    parentPoint = NULL;
    associatedCSN = NULL;
  }


@@ -145,7 +141,6 @@ namespace Isis {
      p_loggedData = NULL;
    }

    associatedCSN = NULL;
  }


@@ -1055,7 +1050,6 @@ namespace Isis {
    p_focalPlaneMeasuredY = other.p_focalPlaneMeasuredY;
    p_focalPlaneComputedX = other.p_focalPlaneComputedX;
    p_focalPlaneComputedY = other.p_focalPlaneComputedY;
    associatedCSN = other.associatedCSN;

    return *this;
  }
+4 −4
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ namespace Isis {
  class Camera;
  class ControlMeasureLogData;
  class ControlPoint;
  class ControlCubeGraphNode;
  class PvlGroup;
  class PvlKeyword;

@@ -175,13 +174,16 @@ 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 {

      Q_OBJECT

      friend class ControlPoint;
      friend class ControlCubeGraphNode;
    public:
      /**
       * @brief Control network measurement types
@@ -249,7 +251,6 @@ namespace Isis {
      ~ControlMeasure();

      ControlPoint *Parent() { return parentPoint; }
      ControlCubeGraphNode *ControlSN() { return associatedCSN; }

      Status SetAprioriLine(double aprioriLine);
      Status SetAprioriSample(double aprioriSample);
@@ -333,7 +334,6 @@ namespace Isis {

    private: // data
      ControlPoint *parentPoint;  //!< Pointer to parent ControlPoint, may be null
      ControlCubeGraphNode *associatedCSN;  //!< Pointer to the Serial Number
      // structure connecting measures in an image

      QString *p_serialNumber;
+225 −493

File changed.

Preview size limit exceeded, changes collapsed.

+39 −84
Original line number Diff line number Diff line
@@ -31,10 +31,16 @@
#include <QMap>
#include <QVector>

// Boost includes
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>

template< typename A, typename B > class QHash;
template< typename T > class QList;
template< typename A, typename B > struct QPair;
template< typename T > class QSet;

class QMutex;
class QString;

@@ -213,6 +219,13 @@ namespace Isis {
   *                           image. Previously, this had to be done throug the graph.
   *   @history 2018-01-26 Kristin Berry - Added pointAdded() function to eliminate redundant measure
   *                           adds to the control network.
   *   @history 2018-01-26 Kristin Berry - Removed unused methods and associated code:
   *                           MinimumSpanningTree(), GetNodeConnections(), RandomBFS(), Shuffle(),
   *                           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. 
   *                           
   *                           
   *   @history 2018-04-05 Adam Goins - Added a check to the versionedReader targetRadii
   *                           group to set radii values to those ingested from the versioner
   *                           if they exist. Otherwise, we call SetTarget with the targetname.
@@ -225,6 +238,11 @@ namespace Isis {
      friend class ControlPoint;

    public:

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

      ControlNet();
      ControlNet(const ControlNet &other);
      ControlNet(const QString &filename, Progress *progress = 0);
@@ -244,19 +262,13 @@ namespace Isis {
      bool ContainsPoint(QString pointId) const;

      QList< QString > GetCubeSerials() const;
      QList< ControlCubeGraphNode * > GetCubeGraphNodes();
      QString GraphToString() const;
      QList< QList< QString > > GetSerialConnections() const;
      QList< QList< ControlCubeGraphNode * > > GetNodeConnections() const;
      QSet< ControlMeasure * > MinimumSpanningTree(
          QList< ControlCubeGraphNode *> &island,
          bool lessThan(const ControlMeasure *, const ControlMeasure *)) const;
      int getEdgeCount() const;
      QString CubeGraphToString() const;
      QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber);
      QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber);
      QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const,
                                                  double min,double max);
      void DeleteMeasuresWithId(QString serialNumber);

      void ComputeResiduals();
      void ComputeApriori();
@@ -266,9 +278,6 @@ namespace Isis {
      const ControlPoint *GetPoint(int index) const;
      ControlPoint *GetPoint(int index);

      const ControlCubeGraphNode *getGraphNode(QString serialNumber) const;
      ControlCubeGraphNode *getGraphNode(QString serialNumber);

      double AverageResidual();
      Isis::Camera *Camera(int index);
      QString CreatedDate() const;
@@ -326,7 +335,7 @@ namespace Isis {

    private:
      void nullify();
      void ValidateSerialNumber(QString serialNumber) const;
      bool ValidateSerialNumber(QString serialNumber) const;
      void measureAdded(ControlMeasure *measure);
      void pointAdded(ControlPoint *point);
      void measureDeleted(ControlMeasure *measure);
@@ -337,11 +346,6 @@ namespace Isis {


    private: // graphing functions
      QList< ControlCubeGraphNode * > RandomBFS(QList <
          ControlCubeGraphNode * > list) const;
      void Shuffle(QList< ControlCubeGraphNode * > & list) const;
      QPair< int, int > CalcBWAndCE(QList< QString > serials) const;

      /**
       * @author 2012-04-13 Orrin Thomas
       *
@@ -366,79 +370,30 @@ namespace Isis {
          double(ControlMeasure::*m_accessor)() const;
      };


      /**
       * Encapsulation of a vertex in a minimum spanning tree.  Can be either a
       * Control Point or a Graph Node.  Each vertex is connected to another by
       * a measure.  A vertex without a parent vertex is considered a root node,
       * or the base of its own tree.
       *
       * @author ????-??-?? Unknown
       *
       * @internal
       */
      class ControlVertex {
        public:
          //! Construct a vertex from a Graph Node
          ControlVertex(ControlCubeGraphNode *node) {
            m_node = node;
            m_point = NULL;
            m_parent = NULL;
          }

          //! Construct a vertex from a Control Point
          ControlVertex(ControlPoint *point) {
            m_point = point;
            m_node = NULL;
            m_parent = NULL;
          }

          //! Does not own any of its private data
          ~ControlVertex() {}

          //! Set the parent vertex, removing the root node status.
          void setParent(ControlVertex *v) { m_parent = v; }

          //! Get the root node, or greatest ancestor
          ControlVertex * getRoot() {
            ControlVertex *current = this;
            while (current->getParent() != NULL)
              current = current->getParent();
            return current;
          }

          //! Get the parent node.  A root node has no parent.
          ControlVertex * getParent() { return m_parent; }

          //! Get the node representation of this vertex
          ControlCubeGraphNode * getNode() { return m_node; }

          //! Get the point representation of this vertex
          ControlPoint * getPoint() { return m_point; }

          //! Join two nodes by setting one root to be the other's parent
          static void join(ControlVertex *v1, ControlVertex *v2) {
            v1->getRoot()->setParent(v2->getRoot());
          }

        private:
          //! The possibly non-existant graph node
          ControlCubeGraphNode *m_node;

          //! The possibly non-existant control point
          ControlPoint *m_point;

          //! The possibly non-existant parent vertex
          ControlVertex *m_parent;
      };


    private: // data
      //! hash ControlPoints by ControlPoint Id
      QHash< QString, ControlPoint * > * points;

      //! hash ControlCubeGraphNodes by CubeSerialNumber
      QHash< QString, ControlCubeGraphNode * > * cubeGraphNodes;

      // structs and typedefs for the boost graph
      struct Image {
        QString serial;
        QHash< ControlPoint *, ControlMeasure * > measures;
      };

      struct Connection {
        int strength = 0;
      };

      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;
      QHash<QString, ImageVertex> m_vertexMap; //!< The SN -> vertex hash for the boost graph
      Network m_controlGraph; //!< The boost graph
      QStringList *pointIds;
      QMutex *m_mutex;

Loading