OpenWalnut  1.5.0dev
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 <memory>
31 #include <string>
32 #include <vector>
33 
34 
35 #include "../common/WTransferable.h"
36 #include "../common/exceptions/WInvalidID.h"
37 #include "WDataSet.h"
38 #include "datastructures/WFiberCluster.h"
39 #include "datastructures/WTreeNode.h"
40 
41 /**
42  * Represents a hierarchy of clusters
43  */
44 class WDataSetHierarchicalClustering : public WDataSet // NOLINT
45 {
46 public:
47  // some type alias for the used arrays.
48  /**
49  * Pointer to dataset.
50  */
51  typedef std::shared_ptr< WDataSetHierarchicalClustering > SPtr;
52 
53  /**
54  * Pointer to const dataset.
55  */
56  typedef std::shared_ptr< const WDataSetHierarchicalClustering > ConstSPtr;
57 
58  /**
59  * Constructs a hierarchical clustering dataset
60  *
61  * \param rootNode the root node of the WTreeNode-tree holding indices to the clusterMap
62  * \param clusterMap a map of fiber clusters accessible via index
63  */
64  WDataSetHierarchicalClustering( WTreeNode::SPtr rootNode, std::map< size_t, WFiberCluster::SPtr > clusterMap );
65 
66  /**
67  * Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
68  */
70 
71  /**
72  * Destructor.
73  */
75 
76  /**
77  * Gets the name of this prototype.
78  *
79  * \return the name.
80  */
81  virtual const std::string getName() const;
82 
83  /**
84  * Gets the description for this prototype.
85  *
86  * \return the description
87  */
88  virtual const std::string getDescription() const;
89 
90  /**
91  * Returns a prototype instantiated with the true type of the deriving class.
92  *
93  * \return the prototype.
94  */
95  static std::shared_ptr< WPrototyped > getPrototype();
96 
97  /**
98  * Returns the root cluster
99  *
100  * \return the root cluster
101  */
103 
104  /**
105  * Returns the whole cluster map
106  *
107  * \return the whole cluster map
108  */
109  std::map< size_t, WFiberCluster::SPtr > getClusterMap();
110 
111  /**
112  * Returns all clusters down (root node has highest level) to a certain level in the hierarchy
113  *
114  * \param node the node used as a starting point for the recursive lookup
115  * \param level the maximum level for a node to be selected
116  * \return the clusters down to a certain level in the hierarchy
117  */
118  std::vector< WTreeNode::SPtr > getClustersDownToLevel( WTreeNode::SPtr node, size_t level );
119 
120 protected:
121  /**
122  * The prototype as singleton.
123  */
124  static std::shared_ptr< WPrototyped > m_prototype;
125 
126 private:
127  /**
128  * Pointer to the root cluster
129  */
131 
132  /**
133  * Stores the cluster map
134  */
135  std::map< size_t, WFiberCluster::SPtr > m_clusters;
136 };
137 
138 #endif // WDATASETHIERARCHICALCLUSTERING_H
Represents a hierarchy of clusters.
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
std::shared_ptr< const WDataSetHierarchicalClustering > ConstSPtr
Pointer to const dataset.
std::shared_ptr< WDataSetHierarchicalClustering > SPtr
Pointer to dataset.
virtual const std::string getName() const
Gets the name of this prototype.
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.
WTreeNode::SPtr m_rootNode
Pointer to the root cluster.
WTreeNode::SPtr getRootNode()
Returns the root cluster.
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
std::map< size_t, WFiberCluster::SPtr > m_clusters
Stores the cluster map.
WDataSetHierarchicalClustering()
Constructs a new set of tracts.
std::map< size_t, WFiberCluster::SPtr > getClusterMap()
Returns the whole cluster map.
virtual const std::string getDescription() const
Gets the description for this prototype.
Base class for all data set types.
Definition: WDataSet.h:50
std::shared_ptr< WTreeNode > SPtr
Shared pointer abbreviation.
Definition: WTreeNode.h:44