MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLTools/include/mlTools.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00010 //----------------------------------------------------------------------------------
00011 #ifndef __mlTools_H
00012 #define __mlTools_H
00013 
00014 // ML-includes
00015 #ifndef __MLToolsSystem_H
00016 #include "MLToolsSystem.h"
00017 #endif
00018 #ifndef __mlModuleIncludes_H
00019 #include <mlModuleIncludes.h>
00020 #endif
00021 
00022 // BitImage class.
00023 #ifndef __mlBitImage_H
00024 #include "mlBitImage.h"
00025 #endif
00026 
00027 // VirtualVolume class.
00028 #ifndef __mlVirtualVolume_H
00029 #include "mlVirtualVolume.h"
00030 #endif
00031 #ifndef __mlTVirtualVolume_H
00032 #include "mlTVirtualVolume.h"
00033 #endif
00034 
00035 // Geometric primitives.
00036 #ifndef __mlDisc_H
00037 #include "mlDisc.h"
00038 #endif
00039 #ifndef __mlSphere_H
00040 #include "mlSphere.h"
00041 #endif
00042 
00043 // These are included from MLLinearAlgebra:
00044 #ifndef __mlLine_H
00045 #include "mlLine.h"
00046 #endif
00047 #ifndef __mlPlane_H
00048 #include "mlPlane.h"
00049 #endif
00050 #ifndef __mlRotation_H
00051 #include "mlRotation.h"
00052 #endif
00053 
00054 // Additional fields.
00055 #ifndef __mlMultiFields_H
00056 #include "mlMultiFields.h"
00057 #endif
00058 
00059 ML_START_NAMESPACE
00060 
00061   //----------------------------------------------------------------------
00064   //----------------------------------------------------------------------
00065   class MLTOOLS_EXPORT Tools {
00066 
00067   public:
00068 
00069     //----------------------------------------------------------------------
00075     //----------------------------------------------------------------------
00076     static MLErrorCode scanInput(Module *op, MLint inIdx,
00077                                  MLdouble &stdMin,  MLdouble &stdMax,
00078                                  MLdouble &realMin, MLdouble &realMax);
00079 
00080     //----------------------------------------------------------------------
00086     //----------------------------------------------------------------------
00087     static MLErrorCode scanOutput(Module *op, MLint outIdx,
00088                                   MLdouble &stdMin,  MLdouble &stdMax,
00089                                   MLdouble &realMin, MLdouble &realMax);
00090 
00091     //----------------------------------------------------------------------
00097     //----------------------------------------------------------------------
00098     static MLErrorCode scanImage(PagedImage &img,
00099                                  MLdouble &stdMin,  MLdouble &stdMax,
00100                                  MLdouble &realMin, MLdouble &realMax);
00101 
00102     //----------------------------------------------------------------------
00108     //----------------------------------------------------------------------
00109     static MLdouble calculateImageCheckSum(MLint outNum, Module &baseOp);
00110 
00111     //----------------------------------------------------------------------
00122     //----------------------------------------------------------------------
00123     static void separate(const std::string &stri, char sep, MLuint &num, std::string *&seps);
00124 
00125     //----------------------------------------------------------------------
00127     //----------------------------------------------------------------------
00128     static void replace(std::string& s, char sch, char rep);
00129 
00130     //----------------------------------------------------------------------
00143     //----------------------------------------------------------------------
00144     static std::string toHex(MLint64 val,
00145                              size_t  minNumDigitSpace = 1,
00146                              bool    useCapitals      = true,
00147                              bool    isSigned         = false);
00148 
00149     //----------------------------------------------------------------------
00168     //----------------------------------------------------------------------
00169     static std::string toString(MLint64 val,
00170                                 size_t  minFieldSize     = 1,
00171                                 int     align            = 1,
00172                                 size_t  preSpaces        = 0,
00173                                 size_t  postSpaces       = 0,
00174                                 int     hex              = 0,
00175                                 size_t  minNumDigitSpace = 8,
00176                                 bool    useCapitals      = true);
00177 
00178     //-------------------------------------------------------------------------------
00181     //-------------------------------------------------------------------------------
00182     static bool appendToLog(const std::string &path, const std::string &logString);
00183 
00184     //-------------------------------------------------------------------------------
00189     //-------------------------------------------------------------------------------
00190     static bool clearLogFile(const std::string &path, bool remove=false);
00191 
00192     //-------------------------------------------------------------------------------
00203     //-------------------------------------------------------------------------------
00204 #ifndef BUILD_WITHOUT_DICOM_DEPENDENCY
00205     static bool getVoxelValueRescale (MedicalImageProperties *img,
00206                                       double &slope, double &intercept, bool inverse = false);
00207 #endif
00208     //-------------------------------------------------------------------------------
00212     //-------------------------------------------------------------------------------
00213     static std::string getTypeInformation(MLDataType dt);
00214 
00215     //----------------------------------------------------------------------------------
00230     //----------------------------------------------------------------------------------
00231 
00232     static void getLoopOrder(int dim, 
00233                              const SubImageBox& calcBox, 
00234                              std::vector<int>& loopOrder,
00235                              std::vector<int>& loopStart, 
00236                              std::vector<int>& loopEnd);
00237 
00238   protected:
00239     //----------------------------------------------------------------------
00243     //----------------------------------------------------------------------
00244     static std::string _separateBuffer(const std::string &str,
00245                                        const std::string &colSep,
00246                                        const std::string &lineSep);
00247 
00248   };
00249 
00250 ML_END_NAMESPACE
00251 
00252 #endif // __mlTools_H
00253