gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Utilities.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2017, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __Utilities_h
36 #define __Utilities_h
37 
38 
66 //******************************************************************************
67 // Include
68 //******************************************************************************
69 #include <string>
70 
71 #ifndef __gVirtualXRayConfig_h
73 #endif
74 
75 
76 //******************************************************************************
77 // namespace
78 //******************************************************************************
79 namespace gVirtualXRay {
80 
81 
82 //------------------------------------------------------------------------------
84 
89 //------------------------------------------------------------------------------
90 int inflate(const void *src, int srcLen, char** apDst);
91 
92 
93 //------------------------------------------------------------------------------
95 
100 //------------------------------------------------------------------------------
101 int deflate(const void *src, int srcLen, char** apDst);
102 
103 
104 //------------------------------------------------------------------------------
106 
110 //------------------------------------------------------------------------------
111 bool isMAT(const char* aFileName);
112 
113 
114 //------------------------------------------------------------------------------
116 
120 //------------------------------------------------------------------------------
121 bool isDAT(const char* aFileName);
122 
123 
124 //------------------------------------------------------------------------------
126 
130 //------------------------------------------------------------------------------
131 bool isTXT(const char* aFileName);
132 
133 
134 //------------------------------------------------------------------------------
136 
140 //------------------------------------------------------------------------------
141 bool isPGM(const char* aFileName);
142 
143 
144 //------------------------------------------------------------------------------
146 
150 //------------------------------------------------------------------------------
151 bool isRAW(const char* aFileName);
152 
153 
154 //------------------------------------------------------------------------------
156 
160 //------------------------------------------------------------------------------
161 bool isMHA(const char* aFileName);
162 
163 
164 //------------------------------------------------------------------------------
166 
170 //------------------------------------------------------------------------------
171 bool isMHD(const char* aFileName);
172 
173 
174 //------------------------------------------------------------------------------
176 
180 //------------------------------------------------------------------------------
181 bool isDCM(const char* aFileName);
182 
183 
184 //------------------------------------------------------------------------------
186 
190 //------------------------------------------------------------------------------
191 bool isJPEG(const char* aFileName);
192 
193 
194 //------------------------------------------------------------------------------
196 
200 //------------------------------------------------------------------------------
201 bool isTIFF(const char* aFileName);
202 
203 
204 //------------------------------------------------------------------------------
206 
210 //------------------------------------------------------------------------------
211 bool isMAT(const std::string& aFileName);
212 
213 
214 //------------------------------------------------------------------------------
216 
220 //------------------------------------------------------------------------------
221 bool isDAT(const std::string& aFileName);
222 
223 
224 //------------------------------------------------------------------------------
226 
230 //------------------------------------------------------------------------------
231 bool isTXT(const std::string& aFileName);
232 
233 
234 //------------------------------------------------------------------------------
236 
240 //------------------------------------------------------------------------------
241 bool isPGM(const std::string& aFileName);
242 
243 
244 //------------------------------------------------------------------------------
246 
250 //------------------------------------------------------------------------------
251 bool isRAW(const std::string& aFileName);
252 
253 
254 //------------------------------------------------------------------------------
256 
260 //------------------------------------------------------------------------------
261 bool isMHA(const std::string& aFileName);
262 
263 
264 //------------------------------------------------------------------------------
266 
270 //------------------------------------------------------------------------------
271 bool isMHD(const std::string& aFileName);
272 
273 
274 //------------------------------------------------------------------------------
276 
280 //------------------------------------------------------------------------------
281 bool isDCM(const std::string& aFileName);
282 
283 
284 //------------------------------------------------------------------------------
286 
290 //------------------------------------------------------------------------------
291 bool isJPEG(const std::string& aFileName);
292 
293 
294 //------------------------------------------------------------------------------
296 
300 //------------------------------------------------------------------------------
301 bool isTIFF(const std::string& aFileName);
302 
303 
304 bool checkExtension(const char* aFileName, const char* anExtension);
305 
306 
307 bool checkExtension(const std::string& aFileName,
308  const std::string& anExtension);
309 
310 
311 bool isBigEndian();
312 
313 
314 bool isLittleEndian();
315 
316 
317 bool isLetter(char aValue);
318 
319 
320 bool isUpperCase(char aValue);
321 
322 
323 bool isLowerCase(char aValue);
324 
325 
326 bool isNumber(char aValue);
327 
328 
329 template<typename T> void swapBytes(T& aValue);
330 
331 
332 template<typename T> T degreeToRadian(const T& aAngleInDegree);
333 
334 
335 template<typename T> T radianToDegree(const T& aAngleInRadian);
336 
337 
338 template <typename T> int sgn(const T& aValue);
339 
340 
341 double interpolate(const double& a_low,
342  const double& a_high,
343  const double& a0,
344  const double& b_low,
345  const double& b_high);
346 
347 
348 float interpolate(const float& a_low,
349  const float& a_high,
350  const float& a0,
351  const float& b_low,
352  const float& b_high);
353 
354 
355 } // namespace gVirtualXRay
356 
357 
358 //******************************************************************************
359 #include "Utilities.inl"
360 
361 
362 #endif // __Utilities_h
bool isRAW(const char *aFileName)
Check if the extension of a file name is RAW.
Definition: Utilities.inl:145
bool isMHD(const char *aFileName)
Check if the extension of a file name is MHD.
Definition: Utilities.inl:177
int inflate(const void *src, int srcLen, char **apDst)
Uncompress data using the Zlib.
bool isLetter(char aValue)
Definition: Utilities.inl:351
bool isBigEndian()
Definition: Utilities.inl:334
bool isDAT(const char *aFileName)
Check if the extension of a file name is DAT.
Definition: Utilities.inl:97
bool isTIFF(const char *aFileName)
Check if the extension of a file name is TIFF.
Definition: Utilities.inl:227
bool isMHA(const char *aFileName)
Check if the extension of a file name is MHA.
Definition: Utilities.inl:161
T degreeToRadian(const T &aAngleInDegree)
Definition: Utilities.inl:403
bool isPGM(const char *aFileName)
Check if the extension of a file name is PGM.
Definition: Utilities.inl:129
Some utility functions that do not fit anywhere else.
T radianToDegree(const T &aAngleInRadian)
Definition: Utilities.inl:411
bool isTXT(const char *aFileName)
Check if the extension of a file name is TXT.
Definition: Utilities.inl:113
bool isJPEG(const char *aFileName)
Check if the extension of a file name is JPEG.
Definition: Utilities.inl:209
bool isLittleEndian()
Definition: Utilities.inl:343
bool isDCM(const char *aFileName)
Check if the extension of a file name is DCM.
Definition: Utilities.inl:193
bool isNumber(char aValue)
Definition: Utilities.inl:376
void swapBytes(T &aValue)
Definition: Utilities.inl:384
bool isUpperCase(char aValue)
Definition: Utilities.inl:360
bool checkExtension(const char *aFileName, const char *anExtension)
Definition: Utilities.inl:325
bool isLowerCase(char aValue)
Definition: Utilities.inl:368
int deflate(const void *src, int srcLen, char **apDst)
Compress data using the Zlib.
int sgn(const T &aValue)
Definition: Utilities.inl:419
bool isMAT(const char *aFileName)
Check if the extension of a file name is MAT.
Definition: Utilities.inl:81
double interpolate(const double &a_low, const double &a_high, const double &a0, const double &b_low, const double &b_high)
Definition: Utilities.inl:427