OpenWalnut  1.4.0
WDataSetHierarchicalClustering.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WDATASETHIERARCHICALCLUSTERING_H_
26 #define WDATASETHIERARCHICALCLUSTERING_H_
27 
28 #include <list>
29 #include <map>
30 #include <string>
31 #include <vector>
32 
33 #ifndef Q_MOC_RUN
34 #include <boost/shared_ptr.hpp>
35 #endif
36 
37 #include "../common/exceptions/WInvalidID.h"
38 #include "../common/WTransferable.h"
39 #include "datastructures/WFiberCluster.h"
40 #include "datastructures/WTreeNode.h"
41 #include "WDataSet.h"
42 
43 /**
44  * Represents a hierarchy of clusters
45  */
46 class WDataSetHierarchicalClustering : public WDataSet // NOLINT
47 {
48 public:
49  // some type alias for the used arrays.
50  /**
51  * Pointer to dataset.
52  */
53  typedef boost::shared_ptr< WDataSetHierarchicalClustering > SPtr;
54 
55  /**
56  * Pointer to const dataset.
57  */
58  typedef boost::shared_ptr< const WDataSetHierarchicalClustering > ConstSPtr;
59 
60  /**
61  * Constructs a hierarchical clustering dataset
62  *
63  * \param rootNode the root node of the WTreeNode-tree holding indices to the clusterMap
64  * \param clusterMap a map of fiber clusters accessible via index
65  */
66  WDataSetHierarchicalClustering( WTreeNode::SPtr rootNode, std::map< size_t, WFiberCluster::SPtr > clusterMap );
67 
68  /**
69  * Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
70  */
72 
73  /**
74  * Destructor.
75  */
77 
78  /**
79  * Gets the name of this prototype.
80  *
81  * \return the name.
82  */
83  virtual const std::string getName() const;
84 
85  /**
86  * Gets the description for this prototype.
87  *
88  * \return the description
89  */
90  virtual const std::string getDescription() const;
91 
92  /**
93  * Returns a prototype instantiated with the true type of the deriving class.
94  *
95  * \return the prototype.
96  */
97  static boost::shared_ptr< WPrototyped > getPrototype();
98 
99  /**
100  * Returns the root cluster
101  *
102  * \return the root cluster
103  */
105 
106  /**
107  * Returns the whole cluster map
108  *
109  * \return the whole cluster map
110  */
111  std::map< size_t, WFiberCluster::SPtr > getClusterMap();
112 
113  /**
114  * Returns all clusters down (root node has highest level) to a certain level in the hierarchy
115  *
116  * \param node the node used as a starting point for the recursive lookup
117  * \param level the maximum level for a node to be selected
118  * \return the clusters down to a certain level in the hierarchy
119  */
120  std::vector< WTreeNode::SPtr > getClustersDownToLevel( WTreeNode::SPtr node, size_t level );
121 
122 protected:
123  /**
124  * The prototype as singleton.
125  */
126  static boost::shared_ptr< WPrototyped > m_prototype;
127 
128 private:
129  /**
130  * Pointer to the root cluster
131  */
133 
134  /**
135  * Stores the cluster map
136  */
137  std::map< size_t, WFiberCluster::SPtr > m_clusters;
138 };
139 
140 #endif // WDATASETHIERARCHICALCLUSTERING_H
virtual const std::string getName() const
Gets the name of this prototype.
std::map< size_t, WFiberCluster::SPtr > getClusterMap()
Returns the whole cluster map.
Base class for all data set types.
Definition: WDataSet.h:55
virtual const std::string getDescription() const
Gets the description for this prototype.
std::map< size_t, WFiberCluster::SPtr > m_clusters
Stores the cluster map.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
WTreeNode::SPtr getRootNode()
Returns the root cluster.
boost::shared_ptr< WDataSetHierarchicalClustering > SPtr
Pointer to dataset.
std::vector< WTreeNode::SPtr > getClustersDownToLevel(WTreeNode::SPtr node, size_t level)
Returns all clusters down (root node has highest level) to a certain level in the hierarchy...
WDataSetHierarchicalClustering()
Constructs a new set of tracts.
Represents a hierarchy of clusters.
boost::shared_ptr< const WDataSetHierarchicalClustering > ConstSPtr
Pointer to const dataset.
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
WTreeNode::SPtr m_rootNode
Pointer to the root cluster.
boost::shared_ptr< WTreeNode > SPtr
Shared pointer abbreviation.
Definition: WTreeNode.h:49