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