Commit 088b404a authored by Adam Goins's avatar Adam Goins
Browse files

Fixed merge conflicts

parents 3b0e0c04 f024deed
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
@@ -322,23 +322,6 @@ void IsisMain() {
    if (net.GetSerialConnections().size() > numInitialIslands) islandFlag = false; //test failed
    else islandFlag = true; //test passed

    //Check to see if the network has split
      //this simplifies to making sure that all cubes observing the ControlPoint that had some or
      //all of it's measures ignored are still connected
    /* //Travis Addair informed me that this method only checks 1 step conections
    // thus it was effectively only enforcing that the last tie between pairs
    // of images not be ingorned
    QList<ControlMeasure *> ptMeas = suspectMeasures[i]->Parent()->getMeasures();
    const ControlCubeGraphNode *node0 = net.getGraphNode(ptMeas[0]->GetCubeSerialNumber());
    islandFlag = true;  //assuming the best, and then verify
    for (int j=1; j<ptMeas.size(); j++) {
      //check each subsequent node for conection to the first
      if ( !node0->isConnected(net.getGraphNode(ptMeas[j]->GetCubeSerialNumber()))) {
        islandFlag = false; //test failed
        break;
      }
    }*/

    //again we will temporarily be setting the measure back to unignored
      //this will change when the expected ControlNet::isCriticalMeasure(...) method is written
    for (int j=0;j<measGroup.size();j++) {
+0 −269
Original line number Diff line number Diff line
#include "IsisDebug.h"

#include "ControlCubeGraphNode.h"

#include <iostream>

#include <QHash>
#include <QString>

#include "ControlMeasure.h"
#include "ControlPoint.h"
#include "IException.h"
#include "IString.h"


namespace Isis {
  /**
  * Create an empty SerialNumber object.
  */
  ControlCubeGraphNode::ControlCubeGraphNode(QString sn) {
    nullify();

    serialNumber = new QString(sn);
    measures = new QHash<ControlPoint *, ControlMeasure *>;
    connections = new QHash < ControlCubeGraphNode *, QList< ControlPoint * > >;
  }


  ControlCubeGraphNode::ControlCubeGraphNode(const ControlCubeGraphNode &other) {
    nullify();

    serialNumber = new QString(*other.serialNumber);
    measures = new QHash<ControlPoint *, ControlMeasure *>;
    connections = new QHash < ControlCubeGraphNode *, QList< ControlPoint * > >;

    *measures = *other.measures;
  }


  void ControlCubeGraphNode::nullify() {
    serialNumber = NULL;
    measures = NULL;
    connections = NULL;
  }


  /**
   * Destroy a SerialNumber object.
  */
  ControlCubeGraphNode::~ControlCubeGraphNode() {
    if (serialNumber) {
      delete serialNumber;
      serialNumber = NULL;
    }

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

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


  /**
   * @param point The ControlPoint to check for
   *
   * @returns true if the point is contained, false otherwise
   */
  bool ControlCubeGraphNode::contains(ControlPoint *point) const {
    return measures->contains(point);
  }


  /**
   * Adds a measure
   *
   * @param measure The ControlMeasure to add
   */
  void ControlCubeGraphNode::addMeasure(ControlMeasure *measure) {
    ASSERT(measure);

    if (measure->GetCubeSerialNumber() != *serialNumber) {
      QString msg = "Attempted to add Control Measure with Cube Serial Number ";
      msg += "[" + measure->GetCubeSerialNumber() + "] does not match Serial ";
      msg += "Number [" + *serialNumber + "]";
      throw IException(IException::User, msg, _FILEINFO_);
    }

//    measure->associatedCSN = this;
    ASSERT(!measures->contains(measure->Parent()));
    (*measures)[measure->Parent()] = measure;
  }


  void ControlCubeGraphNode::removeMeasure(ControlMeasure *measure) {

    if (measures->remove(measure->Parent()) != 1) {
      ASSERT(0);
    }

//    measure->associatedCSN = NULL;
  }


  void ControlCubeGraphNode::addConnection(ControlCubeGraphNode *node,
      ControlPoint *point) {
    ASSERT(node);
    ASSERT(point);

    if (connections->contains(node)) {
      if (!(*connections)[node].contains(point))
        (*connections)[node].append(point);
    }
    else {
      QList< ControlPoint * > newConnectionList;
      newConnectionList.append(point);
      (*connections)[node] = newConnectionList;
    }
  }


  void ControlCubeGraphNode::removeConnection(ControlCubeGraphNode *node,
      ControlPoint *point) {
    ASSERT(node);
    ASSERT(point);
    ASSERT(connections);

    if (connections->contains(node)) {
      if ((*connections)[node].contains(point)) {
        (*connections)[node].removeOne(point);
        if (!(*connections)[node].size())
          connections->remove(node);
      }
    }
  }


  int ControlCubeGraphNode::getMeasureCount() const {
    return measures->size();
  }


  QString ControlCubeGraphNode::getSerialNumber() const {
    return *serialNumber;
  }


  QList< ControlMeasure * > ControlCubeGraphNode::getMeasures() const {
    return measures->values();
  }


  QList< ControlMeasure * > ControlCubeGraphNode::getValidMeasures() const {
    QList< ControlMeasure * > validMeasures;

    QList< ControlMeasure * > measureList = measures->values();
    foreach(ControlMeasure * measure, measureList) {
      if (!measure->IsIgnored())
        validMeasures.append(measure);
    }

    return validMeasures;
  }


  QList< ControlCubeGraphNode * > ControlCubeGraphNode::getAdjacentNodes() const {
    return connections->keys();
  }


  bool ControlCubeGraphNode::isConnected(ControlCubeGraphNode *other) const {
    return connections->contains(other);
  }


  ControlMeasure *ControlCubeGraphNode::getMeasure(ControlPoint *point) {
    if (!measures->contains(point)) {
      QString msg = "point [";
      msg += (QString) point->GetId();
      msg += "] not found in the ControlCubeGraphNode";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    return (*measures)[point];
  }


  const ControlMeasure *ControlCubeGraphNode::getMeasure(
    ControlPoint *point) const {
    if (!measures->contains(point)) {
      QString msg = "point [";
      msg += (QString) point->GetId();
      msg += "] not found in the ControlCubeGraphNode";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    return measures->value(point);
  }


  ControlMeasure *ControlCubeGraphNode::operator[](ControlPoint *point) {
    return getMeasure(point);
  }


  const ControlMeasure *ControlCubeGraphNode::operator[](
    ControlPoint *point) const {
    return getMeasure(point);
  }


  const ControlCubeGraphNode &ControlCubeGraphNode::operator=(
    ControlCubeGraphNode other) {
    if (this == &other)
      return *this;

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

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

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

    serialNumber = new QString;
    measures = new QHash< ControlPoint *, ControlMeasure *>;
    connections = new QHash< ControlCubeGraphNode *, QList< ControlPoint * > >;

    *serialNumber = *other.serialNumber;
    *measures = *other.measures;
    *connections = *other.connections;

    return *this;
  }


  QString ControlCubeGraphNode::connectionsToString() const {
    QHashIterator< ControlCubeGraphNode *, QList< ControlPoint * > > i(
      *connections);

    QStringList serials;
    while (i.hasNext()) {
      i.next();
      QString line = "    " + (QString) i.key()->getSerialNumber();
      line += " :  ";
      for (int j = 0; j < i.value().size(); j++) {
        line += (QString) i.value()[j]->GetId();
        if (j != i.value().size() - 1)
          line += ", ";
      }
      serials << line;
    }
    qSort(serials);

    return serials.join("\n");
  }

}
+0 −118
Original line number Diff line number Diff line
#ifndef ControlCubeGraphNode_h
#define ControlCubeGraphNode_h

/**
 * @file
 * $Revision: 1.8 $
 * $Date: 2008/06/18 18:54:11 $
 *
 *   Unless noted otherwise, the portions of Isis written by the USGS are public
 *   domain. See individual third-party library and package descriptions for
 *   intellectual property information,user agreements, and related information.
 *
 *   Although Isis has been used by the USGS, no warranty, expressed or implied,
 *   is made by the USGS as to the accuracy and functioning of such software
 *   and related material nor shall the fact of distribution constitute any such
 *   warranty, and no responsibility is assumed by the USGS in connection
 *   therewith.
 *
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see
 *   the Privacy &amp; Disclaimers page on the Isis website,
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */

#include <QObject>

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

class QString;

namespace Isis {
  class ControlMeasure;
  class ControlPoint;

  /**
   * @brief Serial Number with added functionality for Control Networks
   *
   * This class is extends the Serial Number class in order to directly point
   * between its associated measures in a Control Network and back.
   *
   * @ingroup ControlNetwork
   *
   * @author 2011-01-14 Travis Addair and Christopher Austin
   *
   * @see ControlPoint ControlMeasure
   *
   * @internal
   *   @history 2011-01-14 Travis Addair and Christopher Austin - original
   *                version
   *   @history 2011-02-18 Eric Hyer - This class now also acts as a vertex
   *                class for a graph where edges are the connections between
   *                images.  This means that connections are stored to other
   *                ControlCubeGraphNode objects who have measures which have
   *                the same parent (point) as measures here.
   *   @history 2011-02-22 Eric Hyer - Added isConnected() and
   *                getAdjacentNodes methods
   *   @history 2011-03-15 Eric Hyer - Connections handled more simply - fixed
   *                connection related bugs
   *   @history 2011-06-22 James Alexander Crough and Eric Hyer- Added 
   *                getValidMeasures method.
   *   @history 2011-07-29 Jai Rideout, Steven Lambright, and Eric Hyer - Made
   *                           this inherit from QObject to get destroyed()
   *                           signal
   */
  class ControlCubeGraphNode : public QObject {

      Q_OBJECT

    public:
      explicit ControlCubeGraphNode(QString sn);
      ControlCubeGraphNode(const ControlCubeGraphNode &other);
      virtual ~ControlCubeGraphNode();

      void addMeasure(ControlMeasure *measure);
      void removeMeasure(ControlMeasure *measure);
      void addConnection(ControlCubeGraphNode *, ControlPoint *);
      void removeConnection(ControlCubeGraphNode *, ControlPoint *);

      bool contains(ControlPoint *point) const;
      QString getSerialNumber() const;
      int getMeasureCount() const;
      QList< ControlMeasure * > getMeasures() const;
      QList< ControlMeasure * > getValidMeasures() const;
      QList< ControlCubeGraphNode * > getAdjacentNodes() const;
      bool isConnected(ControlCubeGraphNode *other) const;

      ControlMeasure *getMeasure(ControlPoint *point);
      const ControlMeasure *getMeasure(ControlPoint *point) const;
      ControlMeasure *operator[](ControlPoint *point);
      const ControlMeasure *operator[](ControlPoint *point) const;

      const ControlCubeGraphNode &operator=(ControlCubeGraphNode);

      QString connectionsToString() const;


    private:
      void nullify();


    private:
      QString *serialNumber;

      //! ControlMeasures hashed by ControlPoint
      QHash< ControlPoint *, ControlMeasure * > * measures;

      /**
       * Stores a list of ControlPoints which establish a conection to the
       * ControlCubeGraphNode that the list is hashed by
       */
      QHash< ControlCubeGraphNode *, QList< ControlPoint * > > * connections;

  };
}

#endif
+0 −26
Original line number Diff line number Diff line
Test adding first measure ...
Key = Point1
Value = measure with cube serial number Image1
Successfully added measure

Test adding second measure ...
Key = Point1
Value = measure with cube serial number Image2
**USER ERROR** Attempted to add Control Measure with Cube Serial Number [Image2] does not match Serial Number [Image1].

Test adding third measure ...
Key = Point2
Value = measure with cube serial number Image1
Successfully added measure

Test adding fourth measure ...
Key = Point2
Value = measure with cube serial number Image2
**USER ERROR** Attempted to add Control Measure with Cube Serial Number [Image2] does not match Serial Number [Image1].

Testing getMeasures method...
   (Image1)
   (Image1)

Testing getValidMeasures method...
   (Image1)
+0 −7
Original line number Diff line number Diff line
ifeq ($(ISISROOT), $(BLANK))
.SILENT:
error:
	echo "Please set ISISROOT";
else
	include $(ISISROOT)/make/isismake.objs
endif
 No newline at end of file
Loading