TapePositioningSystem/Cluster.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of TapePositioningSystem.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  
00019 **
00020 **  Created: 2012-11-16
00021 **  Authors:
00022 **    Marc Wathelet (ISTerre, Grenoble, France)
00023 **
00024 ***************************************************************************/
00025 
00026 #ifndef CLUSTER_H
00027 #define CLUSTER_H
00028 
00029 #include <QGpCoreTools.h>
00030 
00031 #include "TapePositioningSystemDLLExport.h"
00032 
00033 namespace TapePositioningSystem {
00034 
00035   class Node;
00036   class Anchoring;
00037 
00038   class TAPEPOSITIONINGSYSTEM_EXPORT Cluster
00039   {
00040   public:
00041     Cluster();
00042     Cluster(const Cluster& o);
00043     ~Cluster() {}
00044 
00045     bool operator==(const Cluster& o) const;
00046     bool operator<(const Cluster& o) const;
00047 
00048     enum Type {None, Quad, StrongQuad, WeakQuad};
00049 
00050     Type type() const {return _type;}
00051     QString name() const;
00052     double distance(Node * node1, Node * node2) const;
00053     Point2D coordinates(Node * node) const {return _nodes[node];}
00054 
00055     void setOrigin(Node * node);
00056     bool setQuad(QList<Node *> nodes);
00057     bool setCoordinateSystem(Node * origin, Node * north, Node * eastward);
00058 
00059     Anchoring * anchoring(const Cluster& quad) const;
00060     bool add(const Cluster& quad, const Anchoring * anchoring);
00061 
00062     bool isRobustQuad(double stddev) const;
00063 
00064     QList<Node *> nodes() const {return _nodes.keys();}
00065     int count() const {return _nodes.count();}
00066     QMap<Node *, Point2D>::const_iterator find(Node * node) const {return _nodes.find(node);}
00067     QMap<Node *, Point2D>::const_iterator end() const {return _nodes.end();}
00068     bool contains(Node * node) const {return _nodes.contains(node);}
00069 
00070     static bool lessThan(const Cluster * c1, const Cluster * c2) {return *c1<*c2;}
00071     static bool equal(const Cluster * c1, const Cluster * c2) {return *c1==*c2;}
00072   private:
00073     bool calculateStrongQuad(QList<Node *> nodes);
00074     bool calculateWeakQuad(Node * a, QList<Node *> nodes);
00075     static bool isRobustTriangle(const Point2D& a, const Point2D& b, const Point2D& c, double stddev);
00076 
00077     Type _type;
00078     Node * _origin;
00079     QMap<Node *, Point2D> _nodes;
00080   };
00081 
00082 } // namespace TapePositioningSystem
00083 
00084 #endif // CLUSTER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines