MeVisLab Toolbox Reference
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:
27
30
32 WEMPrimitiveValueList(std::string description);
33
36
39
42
44 inline std::string getDescription() const { return _description; }
45
47 inline std::string getUnits() const { return _units; }
49 inline void setUnits(std::string units) { _units = units; }
50
52 inline PrimitiveValueListTypes getPrimitiveValueListType() const { return _primitiveValueListType; }
55
58 bool isValid()const;
60 inline unsigned int getNumValues() const { return static_cast<unsigned int>(_values.size()); }
61
63 inline bool isPersistent() const { return _persistent; }
65 inline void setPersistence(bool persistent) { _persistent = persistent; }
66
68 inline MLDataType getDataType() const { return _dataType; }
70 inline void setDataType(MLDataType dataType) { _dataType = dataType; }
71
73 inline double getMinValue() const { return _minValue; }
75 inline double getMaxValue() const { return _maxValue; }
77 inline double getMeanValue() const { return _meanValue; }
79 inline double getStandardDeviationValue() const { return _stdValue; }
81 inline double getRootMeanSquareDeviationValue() const { return _rmsdValue; }
82
84 inline void setMinMaxValue(double minValue, double maxValue) { _minValue = minValue; _maxValue = maxValue; _fixedMinMaxValues = true; }
88 void clampMinValue(double minValue);
90 void clampMaxValue(double maxValue);
91
94
96 inline double getValue(unsigned int index) const { return (index < _values.size()) ? _values[index] : 0.0; }
99 void setValue(unsigned int index, double value);
102 inline void appendValue(double value) { _values.push_back(value); }
104 inline void setValueFrom(unsigned int index, unsigned int source) { _values[index] = _values[source]; }
106 inline void addValueFrom(unsigned int index, unsigned int source, double modifier) { _values[index] += _values[source] * modifier; }
107
111 void initializeValues(unsigned int number, double value);
117 void extendValues(unsigned int number, double value);
118
121 void resize(unsigned int numValues);
122
126 void loadFrom(FileMapWrapper& mapper, short version);
127
133 inline double getStdValue() const { return getStandardDeviationValue(); }
135 inline double getRMSDValue() const { return getRootMeanSquareDeviationValue(); }
137
139 std::vector<double>& values() { return _values; }
140
142 const std::vector<double>& constValues() const { return _values; }
143
146
147private:
148
150 std::string _description;
151
153 std::string _units;
154
156 PrimitiveValueListTypes _primitiveValueListType;
157
159 MLDataType _dataType;
160
162 bool _fixedMinMaxValues;
163
165 double _minValue;
167 double _maxValue;
169 double _meanValue;
171 double _stdValue;
173 double _rmsdValue;
174
176 std::vector<double> _values;
177
179 bool _persistent;
180};
181
183
#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.
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:596
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
PrimitiveValueListTypes
Enumeration of primitive value list types.