MeVisLab Toolbox Reference
mlTools.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_TOOLS_H
14#define ML_TOOLS_H
15
16
18
19// ML-includes
20#include "MLToolsSystem.h"
21#include <mlModuleIncludes.h>
22
23// BitImage class.
24#include "mlBitImage.h"
25
26// VirtualVolume class.
27#include "mlVirtualVolume.h"
28#include "mlTVirtualVolume.h"
29
30// Geometric primitives.
31#include "mlDisc.h"
32#include "mlSphere.h"
33
34// These are included from MLLinearAlgebra:
35#include "mlLine.h"
36#include "mlPlane.h"
37#include "mlRotation.h"
38
39// Additional fields.
40#include "mlMultiFields.h"
41
43
44 //----------------------------------------------------------------------
47 //----------------------------------------------------------------------
49
50 public:
51
52 //----------------------------------------------------------------------
58 //----------------------------------------------------------------------
62
63 //----------------------------------------------------------------------
69 //----------------------------------------------------------------------
73
74 //----------------------------------------------------------------------
81 //----------------------------------------------------------------------
86 void* progressCallbackUserData = nullptr);
87
88 //----------------------------------------------------------------------
94 //----------------------------------------------------------------------
96
97 //----------------------------------------------------------------------
108 //----------------------------------------------------------------------
109 static void separate(const std::string &stri, char sep, MLuint &num, std::string *&seps);
110
111 //----------------------------------------------------------------------
113 //----------------------------------------------------------------------
114 static void replace(std::string& s, char sch, char rep);
115
116 //----------------------------------------------------------------------
129 //----------------------------------------------------------------------
130 static std::string toHex(MLint64 val,
131 size_t minNumDigitSpace = 1,
132 bool useCapitals = true,
133 bool isSigned = false);
134
135 //----------------------------------------------------------------------
154 //----------------------------------------------------------------------
155 static std::string toString(MLint64 val,
156 size_t minFieldSize = 1,
157 int align = 1,
158 size_t preSpaces = 0,
159 size_t postSpaces = 0,
160 int hex = 0,
161 size_t minNumDigitSpace = 8,
162 bool useCapitals = true);
163
164 //-------------------------------------------------------------------------------
167 //-------------------------------------------------------------------------------
168 static bool appendToLog(const std::string &path, const std::string &logString);
169
170 //-------------------------------------------------------------------------------
175 //-------------------------------------------------------------------------------
176 static bool clearLogFile(const std::string &path, bool remove=false);
177
178 //-------------------------------------------------------------------------------
189 //-------------------------------------------------------------------------------
190#ifndef BUILD_WITHOUT_DICOM_DEPENDENCY
192 double &slope, double &intercept, bool inverse = false);
193#endif
194 //-------------------------------------------------------------------------------
198 //-------------------------------------------------------------------------------
199 static std::string getTypeInformation(MLDataType dt);
200
201 //----------------------------------------------------------------------------------
216 //----------------------------------------------------------------------------------
217
218 static void getLoopOrder(int dim,
219 const SubImageBox& calcBox,
220 std::vector<int>& loopOrder,
221 std::vector<int>& loopStart,
222 std::vector<int>& loopEnd);
223
224 protected:
231
237 void* progressCallbackUserData = nullptr);
238
239 //----------------------------------------------------------------------
243 //----------------------------------------------------------------------
244 static std::string _separateBuffer(const std::string &str,
245 const std::string &colSep,
246 const std::string &lineSep);
247
248 };
249
251
252#endif // __mlTools_H
253
#define MLTOOLS_EXPORT
Resolves system dependencies for this project.
This class encapsulates basic medical image properties:
Base class for an image processing module of the ML.
Definition mlModule.h:151
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Class which collects some useful functions needed in many places of operator programming.
Definition mlTools.h:48
static MLErrorCode scanInput(Module *op, MLint inIdx, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
Analyzes the image at input inIdx of module op for min/max values with the scanImage function.
static std::string _separateBuffer(const std::string &str, const std::string &colSep, const std::string &lineSep)
Return a string from str separated with column and line separator strings colSep and lineSep replacin...
static MLErrorCode scanImageWithGetTile(PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
Helper method that scans image using getTile().
static void separate(const std::string &stri, char sep, MLuint &num, std::string *&seps)
Get a separation of the string into substrings which are separated by the character sep.
static std::string getTypeInformation(MLDataType dt)
Return a string representing an information table about the data type dt.
static MLErrorCode scanImageWithProcessAllPages(PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax, MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
Helper method that is used by scanInput and that uses processAllPages.
static MLdouble calculateImageCheckSum(MLint outNum, Module &baseOp)
Compute a checksum of the output outNum of Module baseOp.
static bool getVoxelValueRescale(MedicalImageProperties *img, double &slope, double &intercept, bool inverse=false)
Return voxel value rescale parameters for img in slope and intercept, describing the transformation f...
static bool clearLogFile(const std::string &path, bool remove=false)
If remove is false then the contents of log file specified by path are cleared, i....
static MLErrorCode scanOutput(Module *op, MLint outIdx, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax)
Analyzes the image at output outIdx of module op for min/max values with the scanImage function.
static void replace(std::string &s, char sch, char rep)
Replaces all occurrences of character sch in s by rep.
static std::string toHex(MLint64 val, size_t minNumDigitSpace=1, bool useCapitals=true, bool isSigned=false)
Returns hexadecimal string from val.
static bool appendToLog(const std::string &path, const std::string &logString)
Append message logString to the log file specified by path path.
static MLErrorCode scanImage(PagedImage &img, MLdouble &stdMin, MLdouble &stdMax, MLdouble &realMin, MLdouble &realMax, MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
Analyzes the given image for min/max values.
static std::string toString(MLint64 val, size_t minFieldSize=1, int align=1, size_t preSpaces=0, size_t postSpaces=0, int hex=0, size_t minNumDigitSpace=8, bool useCapitals=true)
Returns val converted to a std::string.
static void getLoopOrder(int dim, const SubImageBox &calcBox, std::vector< int > &loopOrder, std::vector< int > &loopStart, std::vector< int > &loopEnd)
Return a suitable loop order, i.e., the order in which the six dimensions x,y,z,c,...
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:596
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:716
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
void MLRequestProgressCB(void *usrData, double progress)
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
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition mlTypeDefs.h:412
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