MeVisLab Toolbox Reference
mlClusterRefCollection.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_CLUSTER_REF_COLLECTION_H
14#define ML_CLUSTER_REF_COLLECTION_H
15
16
18
29
30#include "mlClusterInfo.h"
31
32
34
35
37// class ClusterRefType
39
43{
44public:
45 // Default constructor
47 link(nullptr)
48 {
49 }
50
51 // Following methods return by reference to grant
52 // access to the protected members of ClusterInfo,
53 // so that values can be changed by ClusterRefCollection.
54
66
67 // The protected id from ClusterInfo is also used as
68 // index in _clusterRefs, so don't change!
69};
70
71
72
74
83{
84public:
85
86 // Constructor (recommended to use this one if possible, since it sets the initial array size already)
88
89 // Default destructor
91
93 void init(MLuint numVoxels);
94
99
102
107
109 const ClusterInfo& getClusterInfo(MLuint reference) const;
112 const ClusterInfo& getClusterAt(MLuint rank) const;
114 void setUserDataAtRank(MLuint rank, MLdouble userData);
115
120
122 ML_FORCE_INLINE const ClusterInfo& getBackground() const { return _backgroundCluster; }
123
127 std::vector<ClusterInfo> getClusterInfoList() const;
128
131
133 MLuint getNumClusters() const { return _numCluster; }
136
137private:
138 // --- methods ---
139
141 void resize();
142
145 {
147 while (root->link != nullptr)
148 {
149 root = root->link;
150 }
151 return root;
152 }
153
154 MLuint getTotalNumVoxelsInClusters(const std::vector<ClusterRefType>& clusters) const;
155 void countClustersAndCopyToSortVector();
156 void countVoxelsForClusters();
157 void setRankAndUserDataToClusters(const ClusterUserDataParameters& userDataParameters);
158 void setRankAndUserDataToBackgroundCluster(const ClusterUserDataParameters& userDataParameters);
159
160 // --- members ---
161
163 MLuint _initialCapacity;
164
166 ClusterRefType* _clusterRefs;
167
168 ClusterRefType _backgroundCluster;
169
171 MLuint _numReferences;
172
175 MLuint _numCluster;
176
178 MLuint _capacity;
179 MLuint _numVoxels;
180
183 std::vector<ClusterRefType> _clustersSortedBySize;
184};
185
187
188
189#endif // __mlClusterRefCollection_H
Holds basic information about a cluster.
Class for handling cluster references.
MLuint getNumClusters() const
Returns the number of clusters.
ML_FORCE_INLINE const ClusterInfo & getBackground() const
Returns the background cluster info.
MLuint getNumVoxelsInCluster(MLuint rankId) const
Returns the number of voxels of the cluster with the given rank id.
void init(MLuint numVoxels)
Clear ClusterRefCollection and set it to an initialized state.
MLuint merge(MLuint ref1, MLuint ref2)
Merges cluster determined by ref1 and ref2.
void addPositionToBackgroundBoundingBox(MLint x, MLint y, MLint z)
Adds the given positions to the bounding box of the background cluster.
const ClusterInfo & getClusterAt(MLuint rank) const
Returns the cluster info for a given rank.
ClusterRefCollection(MLuint initialCapacity=10)
void calcClusterSizes(const ClusterUserDataParameters &userDataParameters)
Calculates the cluster sizes and sorts the found cluster by size.
const ClusterInfo & getClusterInfo(MLuint reference) const
Returns the cluster info for the given reference.
MLuint getNewReference(MLdouble imageValue)
Returns a new, unique cluster reference.
void incrementClusterSize(MLuint reference)
Increments the size of cluster pointed to by reference.
void addPositionToClusterBoundingBox(MLuint rank, MLint x, MLint y, MLint z)
Adds the given positions to the bounding box of the cluster with the given rank.
void setUserDataAtRank(MLuint rank, MLdouble userData)
Sets the user data value for a cluster with the given rank.
std::vector< ClusterInfo > getClusterInfoList() const
Returns a list of all clusters.
Container class derived from ClusterInfo.
ML_FORCE_INLINE void setNumVoxels(MLuint newNumVoxels)
Sets the cluster size in voxel.
ML_FORCE_INLINE void setIndexId(MLuint newIndex)
Sets a table index.
ML_FORCE_INLINE void setRank(MLuint newRank)
Sets the rank of the cluster.
ClusterRefType * link
Holds pointer to another element in array stored in ClusterRefCollection.
#define ML_FORCE_INLINE
Forcing the use of 'inline' for methods.
Definition mlMacros.h:54
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:506
double MLdouble
Definition mlTypeDefs.h:217
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
Cluster user data parameters.