MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
WEMPrimitiveValueList.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#pragma once
14
15#include "MLWEMIncludes.h"
17
19
21
25{
26public:
29
31 WEMPrimitiveValueList(std::string description);
32
35
38
43
45 inline std::string getDescription() const
46 {
47 return _description;
48 }
49
51 inline std::string getUnits() const
52 {
53 return _units;
54 }
56 inline void setUnits(std::string units)
57 {
58 _units = units;
59 }
60
63 {
64 return _primitiveValueListType;
65 }
71
75 bool isValid() const;
77 inline unsigned int getNumValues() const
78 {
79 return static_cast<unsigned int>(_values.size());
80 }
81
83 inline bool isPersistent() const
84 {
85 return _persistent;
86 }
88 inline void setPersistence(bool persistent)
89 {
90 _persistent = persistent;
91 }
92
94 inline MLDataType getDataType() const
95 {
96 return _dataType;
97 }
99 inline void setDataType(MLDataType dataType)
100 {
101 _dataType = dataType;
102 }
103
105 inline double getMinValue() const
106 {
107 return _minValue;
108 }
110 inline double getMaxValue() const
111 {
112 return _maxValue;
113 }
115 inline double getMeanValue() const
116 {
117 return _meanValue;
118 }
120 inline double getStandardDeviationValue() const
121 {
122 return _stdValue;
123 }
126 {
127 return _rmsdValue;
128 }
129
131 inline void setMinMaxValue(double minValue, double maxValue)
132 {
133 _minValue = minValue;
134 _maxValue = maxValue;
135 _fixedMinMaxValues = true;
136 }
143
146
148 inline double getValue(unsigned int index) const
149 {
150 return (index < _values.size()) ? _values[index] : 0.0;
151 }
154 void setValue(unsigned int index, double value);
157 inline void appendValue(double value)
158 {
159 _values.push_back(value);
160 }
162 inline void setValueFrom(unsigned int index, unsigned int source)
163 {
164 _values[index] = _values[source];
165 }
167 inline void addValueFrom(unsigned int index, unsigned int source, double modifier)
168 {
169 _values[index] += _values[source] * modifier;
170 }
171
175 void initializeValues(unsigned int number, double value);
181 void extendValues(unsigned int number, double value);
182
185 void resize(unsigned int numValues);
186
190 void loadFrom(FileMapWrapper& mapper, short version);
191
197 [[deprecated("Use getStandardDeviationValue() instead.")]]
198 inline double getStdValue() const
199 {
200 return getStandardDeviationValue();
201 }
203 [[deprecated("Use getRootMeanSquareDeviationValue() instead.")]]
204 inline double getRMSDValue() const
205 {
206 return getRootMeanSquareDeviationValue();
207 }
209
211 std::vector<double>& values()
212 {
213 return _values;
214 }
215
217 const std::vector<double>& constValues() const
218 {
219 return _values;
220 }
221
224
225private:
227 std::string _description;
228
230 std::string _units;
231
233 PrimitiveValueListTypes _primitiveValueListType;
234
236 MLDataType _dataType;
237
239 bool _fixedMinMaxValues;
240
242 double _minValue;
244 double _maxValue;
246 double _meanValue;
248 double _stdValue;
250 double _rmsdValue;
251
253 std::vector<double> _values;
254
256 bool _persistent;
257};
258
260
#define MLWEM_EXPORT
Definition MLWEMSystem.h:18
Wraps a FileMap so we can handle errors and exceptions more easily.
Stores a value list where the values are associated to primitives (WEMNode, WEMEdge,...
void extendValues(unsigned int number, double value)
Extends the list with the given amount and initializes new values with that given value.
void setValue(unsigned int index, double value)
Sets the given value at the given index.
void resetValues()
Clears the internal values and resets the min/max and statistical values.
void multiplyValues(double modifier)
Multiplies all values with the given modifier.
double getRootMeanSquareDeviationValue() const
Returns the root mean sqaure deviation value. Make sure to have called updateStatistics() before!
void setPersistence(bool persistent)
Sets whether the value list should be saved when saving the WEM.
std::string getDescription() const
Returns the description of this PVL.
void saveTo(OutStreamWrapper &ostreamWrapper)
Saves attributes to the given output stream.
PrimitiveValueListTypes getPrimitiveValueListType() const
Returns the primitive mode.
const std::vector< double > & constValues() const
Get access to the underlying array.
void copyProperties(const WEMPrimitiveValueList &valueList)
Copies properties of the given primitive value list.
WEMPrimitiveValueList(const WEMPrimitiveValueList &valueList)
Copy constructor.
~WEMPrimitiveValueList()
Destructor.
void initializeValues(unsigned int number, double value)
Initializes the first number of values with the given value.
WEMPrimitiveValueList(std::string description)
Constructor.
double getStandardDeviationValue() const
Returns the standard deviation value. Make sure to have called updateStatistics() before!
void addValueFrom(unsigned int index, unsigned int source, double modifier)
Adds the value from the index source to the given index. The min and max values are not adjusted.
void setUnits(std::string units)
Sets the units string.
void resize(unsigned int numValues)
Resizes the PVL to the given number of values.
void loadFrom(FileMapWrapper &mapper, short version)
Loads attributes from the given memory map.
void setMinMaxValue(double minValue, double maxValue)
Sets the min and max values, switches to fixed values.
void computeAndSetMinMaxFixedValues()
Computes the min and max values, sets them and switches to fixed values.
double getRMSDValue() const
Use getRootMeanSquareDeviationValue() instead.
double getValue(unsigned int index) const
Returns the value at the given index.
MLDataType getDataType() const
Returns the data type.
void removeLastEntry()
Removes the last entry, shortens the list.
void clampMinValue(double minValue)
Clamps all values to the given min value.
void setDataType(MLDataType dataType)
Sets the data type.
double getMeanValue() const
Returns the mean value. Make sure to have called updateStatistics() before!
std::vector< double > & values()
Get access to the underlying array.
void appendValue(double value)
Appends the given value.
double getMaxValue() const
Returns the maximum value.
void updateStatistics()
Update statistics: mean, standard deviation, and root mean square deviation.
void clampMaxValue(double maxValue)
Clamps all values to the given max value.
double getMinValue() const
Returns the minimum value.
bool isPersistent() const
Returns whether this PVL should be saved when saving the WEM?
std::string getUnits() const
Returns the units string.
WEMPrimitiveValueList()
Constructor.
void setValueFrom(unsigned int index, unsigned int source)
Copies the value from the index source to the given index.
void copyFrom(const WEMPrimitiveValueList &valueList)
Copies properties and values from the given primitive value list.
unsigned int getNumValues() const
Returns the number of values.
void setPrimitiveValueListType(PrimitiveValueListTypes primitiveValueListType)
Sets the primitive mode.
bool isValid() const
Returns whether the values are valid? The description should be non-empty, the list should contain va...
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:592
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
PrimitiveValueListTypes
Enumeration of primitive value list types.