OpenWalnut  1.4.0
WDataSetHierarchicalClustering.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WDATASETHIERARCHICALCLUSTERING_H_
00026 #define WDATASETHIERARCHICALCLUSTERING_H_
00027 
00028 #include <list>
00029 #include <map>
00030 #include <string>
00031 #include <vector>
00032 
00033 #include <boost/shared_ptr.hpp>
00034 
00035 #include "../common/exceptions/WInvalidID.h"
00036 #include "../common/WTransferable.h"
00037 #include "datastructures/WFiberCluster.h"
00038 #include "datastructures/WTreeNode.h"
00039 #include "WDataSet.h"
00040 
00041 /**
00042  * Represents a hierarchy of clusters
00043  */
00044 class WDataSetHierarchicalClustering : public WDataSet // NOLINT
00045 {
00046 public:
00047     // some type alias for the used arrays.
00048     /**
00049      * Pointer to dataset.
00050      */
00051     typedef boost::shared_ptr< WDataSetHierarchicalClustering > SPtr;
00052 
00053     /**
00054      * Pointer to const dataset.
00055      */
00056     typedef boost::shared_ptr< const WDataSetHierarchicalClustering > ConstSPtr;
00057 
00058      /**
00059      * Constructs a hierarchical clustering dataset
00060      *
00061      * \param rootNode the root node of the WTreeNode-tree holding indices to the clusterMap
00062      * \param clusterMap a map of fiber clusters accessible via index
00063      */
00064     WDataSetHierarchicalClustering( WTreeNode::SPtr rootNode, std::map< size_t, WFiberCluster::SPtr > clusterMap );
00065 
00066     /**
00067      * Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
00068      */
00069     WDataSetHierarchicalClustering();
00070 
00071     /**
00072      * Destructor.
00073      */
00074     virtual ~WDataSetHierarchicalClustering();
00075 
00076     /**
00077      * Gets the name of this prototype.
00078      *
00079      * \return the name.
00080      */
00081     virtual const std::string getName() const;
00082 
00083     /**
00084      * Gets the description for this prototype.
00085      *
00086      * \return the description
00087      */
00088     virtual const std::string getDescription() const;
00089 
00090     /**
00091      * Returns a prototype instantiated with the true type of the deriving class.
00092      *
00093      * \return the prototype.
00094      */
00095     static boost::shared_ptr< WPrototyped > getPrototype();
00096 
00097     /**
00098      * Returns the root cluster
00099      *
00100      * \return the root cluster
00101      */
00102     WTreeNode::SPtr getRootNode();
00103 
00104     /**
00105      * Returns the whole cluster map
00106      *
00107      * \return the whole cluster map
00108      */
00109     std::map< size_t, WFiberCluster::SPtr > getClusterMap();
00110 
00111     /**
00112      * Returns all clusters down (root node has highest level) to a certain level in the hierarchy
00113      *
00114      * \param node the node used as a starting point for the recursive lookup
00115      * \param level the maximum level for a node to be selected
00116      * \return the clusters down to a certain level in the hierarchy
00117      */
00118     std::vector< WTreeNode::SPtr > getClustersDownToLevel( WTreeNode::SPtr node, size_t level );
00119 
00120 protected:
00121     /**
00122      * The prototype as singleton.
00123      */
00124     static boost::shared_ptr< WPrototyped > m_prototype;
00125 
00126 private:
00127     /**
00128      * Pointer to the root cluster
00129      */
00130     WTreeNode::SPtr m_rootNode;
00131 
00132     /**
00133      * Stores the cluster map
00134      */
00135     std::map< size_t, WFiberCluster::SPtr > m_clusters;
00136 };
00137 
00138 #endif  // WDATASETHIERARCHICALCLUSTERING_H