MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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 : ClusterInfo()
48 , link(nullptr)
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
57 {
58 _indexId = newIndex;
59 }
67 {
68 _rank = newRank;
69 }
75
76 // The protected id from ClusterInfo is also used as
77 // index in _clusterRefs, so don't change!
78};
79
80
82
91{
92public:
93 // Constructor (recommended to use this one if possible, since it sets the initial array size already)
95
96 // Default destructor
98
100 void init(MLuint numVoxels);
101
106
109
114
116 const ClusterInfo& getClusterInfo(MLuint reference) const;
119 const ClusterInfo& getClusterAt(MLuint rank) const;
121 void setUserDataAtRank(MLuint rank, MLdouble userData);
122
127
130 {
131 return _backgroundCluster;
132 }
133
137 std::vector<ClusterInfo> getClusterInfoList() const;
138
141
144 {
145 return _numCluster;
146 }
149
150private:
151 // --- methods ---
152
154 void resize();
155
158 {
160 while (root->link != nullptr) {
161 root = root->link;
162 }
163 return root;
164 }
165
166 MLuint getTotalNumVoxelsInClusters(const std::vector<ClusterRefType>& clusters) const;
167 void countClustersAndCopyToSortVector();
168 void countVoxelsForClusters();
169 void setRankAndUserDataToClusters(const ClusterUserDataParameters& userDataParameters);
170 void setRankAndUserDataToBackgroundCluster(const ClusterUserDataParameters& userDataParameters);
171
172 // --- members ---
173
175 MLuint _initialCapacity;
176
178 ClusterRefType* _clusterRefs;
179
180 ClusterRefType _backgroundCluster;
181
183 MLuint _numReferences;
184
187 MLuint _numCluster;
188
190 MLuint _capacity;
191 MLuint _numVoxels;
192
195 std::vector<ClusterRefType> _clustersSortedBySize;
196};
197
199
200
201#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:51
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:505
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:489
Cluster user data parameters.