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
18ML_START_NAMESPACE
19
21
25{
26public:
27
30
32 WEMPrimitiveValueList(std::string description);
33
36
39
41 void copyProperties(const WEMPrimitiveValueList& valueList);
43 void copyFrom(const WEMPrimitiveValueList& valueList);
44
46 inline std::string getDescription() const { return _description; }
47
49 inline std::string getUnits() const { return _units; }
51 inline void setUnits(std::string units) { _units = units; }
52
54 inline PrimitiveValueListTypes getPrimitiveValueListType() const { return _primitiveValueListType; }
56 inline void setPrimitiveValueListType(PrimitiveValueListTypes primitiveValueListType) { _primitiveValueListType = primitiveValueListType; }
57
60 bool isValid()const;
62 inline unsigned int getNumValues() const { return static_cast<unsigned int>(_values.size()); }
63
65 inline bool isPersistent() const { return _persistent; }
67 inline void setPersistence(bool persistent) { _persistent = persistent; }
68
70 inline MLDataType getDataType() const { return _dataType; }
72 inline void setDataType(MLDataType dataType) { _dataType = dataType; }
73
75 inline double getMinValue() const { return _minValue; }
77 inline double getMaxValue() const { return _maxValue; }
79 inline double getMeanValue() const { return _meanValue; }
81 inline double getStandardDeviationValue() const { return _stdValue; }
83 inline double getRootMeanSquareDeviationValue() const { return _rmsdValue; }
84
86 inline void setMinMaxValue(double minValue, double maxValue) { _minValue = minValue; _maxValue = maxValue; _fixedMinMaxValues = true; }
90 void clampMinValue(double minValue);
92 void clampMaxValue(double maxValue);
93
96
98 inline double getValue(unsigned int index) const { return (index < _values.size()) ? _values[index] : 0.0; }
101 void setValue(unsigned int index, double value);
104 inline void appendValue(double value) { _values.push_back(value); }
106 inline void setValueFrom(unsigned int index, unsigned int source) { _values[index] = _values[source]; }
108 inline void addValueFrom(unsigned int index, unsigned int source, double modifier) { _values[index] += _values[source] * modifier; }
109
113 void initializeValues(unsigned int number, double value);
116 void multiplyValues(double modifier);
119 void extendValues(unsigned int number, double value);
120
123 void resize(unsigned int numValues);
124
126 void saveTo(OutStreamWrapper& ostreamWrapper);
128 void loadFrom(FileMapWrapper& mapper, short version);
129
135 inline double getStdValue() const { return getStandardDeviationValue(); }
137 inline double getRMSDValue() const { return getRootMeanSquareDeviationValue(); }
139
141 std::vector<double>& values() { return _values; }
142
144 const std::vector<double>& constValues() const { return _values; }
145
148
149private:
150
152 std::string _description;
153
155 std::string _units;
156
158 PrimitiveValueListTypes _primitiveValueListType;
159
161 MLDataType _dataType;
162
164 bool _fixedMinMaxValues;
165
167 double _minValue;
169 double _maxValue;
171 double _meanValue;
173 double _stdValue;
175 double _rmsdValue;
176
178 std::vector<double> _values;
179
181 bool _persistent;
182};
183
185
186ML_END_NAMESPACE
#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:595
PrimitiveValueListTypes
Enumeration of primitive value list types.