OpenWalnut  1.4.0
WHierarchicalTreeVoxels.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 WHIERARCHICALTREEVOXELS_H
26 #define WHIERARCHICALTREEVOXELS_H
27 
28 #include <utility>
29 #include <vector>
30 #include <queue>
31 #include <list>
32 
33 #include <boost/shared_ptr.hpp>
34 
35 #include "WColor.h"
36 
37 #include "WHierarchicalTree.h"
38 
39 
40 /**
41  * Class implements a hierarchical tree and provides helper functions for selection and navigation
42  */
44 {
45 public:
46  /**
47  * standard constructor
48  */
50 
51  /**
52  * destructor
53  */
55 
56  /**
57  * getter
58  * \param cluster the cluster to work on
59  * \return vector of voxels contained by this cluster
60  */
61  std::vector<size_t>getVoxelsForCluster( size_t cluster );
62 
63  /**
64  * A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes
65  * a leaf also counts as a cluster
66  * \param voxelnum the voxel id for this leaf
67  */
68  void addLeaf( size_t voxelnum );
69 
70  /**
71  * adds a cluster to the set, it combines 2 already existing clusters
72  *
73  * \param cluster1 first cluster to add
74  * \param cluster2 second cluster to add
75  * \param customData some arbitrary data stored with the cluster
76  */
77  void addCluster( size_t cluster1, size_t cluster2, float customData );
78 
79  /**
80  * getter
81  * \param leaf
82  * \return the voxel num of a leaf node in the tree
83  */
84  size_t getVoxelNum( size_t leaf );
85 
86  /**
87  * finds the clusters for a given similarity value
88  * \param value
89  * \return all clusters below that value
90  */
91  std::vector< size_t >findClustersForValue( float value );
92 
93  /**
94  * finds the clusters for a given similarity value
95  * \param value only return clusters where the distance in energy level to its parent is large than this value
96  * \param minSize only return clusters with a number of voxels large than minSize
97  * \return all clusters below that value
98  */
99  std::vector< size_t >findClustersForBranchLength( float value, size_t minSize = 100 );
100 
101  /**
102  * finds a number of clusters, the algorithm travers down the tree and will always split the cluster with the
103  * highest energy level.
104  * \param root the cluster to start traversing the tree from
105  * \param number the number of cluster we want to find
106  * \return the clusters
107  */
108  std::vector< size_t >findXClusters( size_t root, size_t number );
109 
110 protected:
111 private:
112  /**
113  * A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes
114  * a leaf also counts as a cluster
115  */
116  void addLeaf();
117 
118  std::vector<size_t>m_voxelnums; //!< stores the voxel id of each leaf node
119 };
120 
121 inline size_t WHierarchicalTreeVoxels::getVoxelNum( size_t leaf )
122 {
123  return m_voxelnums[leaf];
124 }
125 
126 #endif // WHIERARCHICALTREEVOXELS_H
WHierarchicalTreeVoxels()
standard constructor
std::vector< size_t > findXClusters(size_t root, size_t number)
finds a number of clusters, the algorithm travers down the tree and will always split the cluster wit...
std::vector< size_t > getVoxelsForCluster(size_t cluster)
getter
void addLeaf()
A leaf is at the very bottom of the tree, it represents a single fiber or voxel, for several purposes...
std::vector< size_t > m_voxelnums
stores the voxel id of each leaf node
size_t getVoxelNum(size_t leaf)
getter
std::vector< size_t > findClustersForValue(float value)
finds the clusters for a given similarity value
base class for hierarchical tree implementations
std::vector< size_t > findClustersForBranchLength(float value, size_t minSize=100)
finds the clusters for a given similarity value
void addCluster(size_t cluster1, size_t cluster2, float customData)
adds a cluster to the set, it combines 2 already existing clusters
Class implements a hierarchical tree and provides helper functions for selection and navigation...