MeVisLab Toolbox Reference
mlVTKCommonToolFunctions.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 
16 // Include dll-specific settings.
17 #include "mlInitSystemVTKSupport.h"
18 
20 #include "mlModuleIncludes.h"
21 #include <mlUnicode.h>
22 #include <mlFileSystem.h>
23 
24 ML_START_NAMESPACE
25 
26 //---------------------------------------------------------------------------
28 //---------------------------------------------------------------------------
29 MLVTK_SUPPORT_EXPORT std::string mlVTKMakeStdString(const char* str);
30 
31 //---------------------------------------------------------------------------
33 //---------------------------------------------------------------------------
34 MLVTK_SUPPORT_EXPORT std::string mlVTKMakeStdString(const std::string &str);
35 
36 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
42 MLVTK_SUPPORT_EXPORT std::string mlVTKGetLatin1FromUTF8(const std::string &utf8StdString);
43 
44 //---------------------------------------------------------------------------
51 //---------------------------------------------------------------------------
52 MLVTK_SUPPORT_EXPORT std::string & mlVTKGetLatin1FromUTF8Static(const std::string &utf8StdString);
53 
54 //---------------------------------------------------------------------------
59 //---------------------------------------------------------------------------
60 MLVTK_SUPPORT_EXPORT std::string mlVTKGetUTF8FromLatin1(const std::string &latin1StdString);
61 
62 //---------------------------------------------------------------------------
69 //---------------------------------------------------------------------------
70 MLVTK_SUPPORT_EXPORT std::string & mlVTKGetUTF8FromLatin1Static(const std::string &latin1StdString);
71 
72 //---------------------------------------------------------------------------
75 //---------------------------------------------------------------------------
76 template<typename TemplArrElemType>
77 void VTKArrayFromFixedSizeSTLVector(const VTKML_TYPENAME std::vector<TemplArrElemType> &stlVec, TemplArrElemType *arr, size_t TemplArrSize)
78 {
79  // Copy elements to return array.
80  const size_t siz = stlVec.size();
81  for (size_t c=0; c < TemplArrSize; ++c){ arr[c] = (c < siz) ? stlVec[c] : 0; }
82 }
83 
84 //---------------------------------------------------------------------------
88 //---------------------------------------------------------------------------
89 template<typename TemplArrElemType, unsigned int TemplArrSize>
90 const VTKML_TYPENAME std::vector<TemplArrElemType> STLVectorFromFixedSizeVTKArray(const TemplArrElemType *theArray)
91 {
92  typename std::vector<TemplArrElemType> stlVector;
93  for (size_t i=0; i<TemplArrSize; ++i){ stlVector.push_back(theArray[i]); }
94  return stlVector;
95 }
96 
97 ML_END_NAMESPACE
#define VTKML_TYPENAME
Define a platform dependent typename macro.
#define MLVTK_SUPPORT_EXPORT
When included by other libraries MLVTK_SUPPORT_EXPORT is compiled as import symbol.
MLVTK_SUPPORT_EXPORT std::string mlVTKGetUTF8FromLatin1(const std::string &latin1StdString)
Convert string from Latin1 to UTF8; return empty string on failure or if "" is passed as latin1StdStr...
MLVTK_SUPPORT_EXPORT std::string & mlVTKGetUTF8FromLatin1Static(const std::string &latin1StdString)
Like mlVTKGetUTF8FromLatin1(const std::string &latin1StdString); the only difference is that the retu...
MLVTK_SUPPORT_EXPORT std::string mlVTKMakeStdString(const std::string &str)
Convert for a std::string to a std::string safely.
MLVTK_SUPPORT_EXPORT std::string mlVTKGetLatin1FromUTF8(const std::string &utf8StdString)
Convert string from UTF8 to Latin1; return empty string on failure or if "" is passed as utf8StdStrin...
void VTKArrayFromFixedSizeSTLVector(const VTKML_TYPENAME std::vector< TemplArrElemType > &stlVec, TemplArrElemType *arr, size_t TemplArrSize)
Copies TemplArrSize elements from stlVec to arr and - if not enough elements are available - fills up...
MLVTK_SUPPORT_EXPORT std::string & mlVTKGetLatin1FromUTF8Static(const std::string &utf8StdString)
Like mlVTKGetLatin1FromUTF8(const std::string &utf8StdString); the only difference is that the return...
const VTKML_TYPENAME std::vector< TemplArrElemType > STLVectorFromFixedSizeVTKArray(const TemplArrElemType *theArray)
Create an STL vector with type TemplArrElemType which contains TemplArrSize elements which are read f...