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