go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elastix.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __elastix_h
19 #define __elastix_h
20 
21 #include "itkUseMevisDicomTiff.h"
22 
23 #include <iostream>
24 #include <iomanip> // std::setprecision
25 #include <string>
26 #include <vector>
27 #include <queue>
28 #include "itkObject.h"
29 #include "itkDataObject.h"
30 #include <itksys/SystemTools.hxx>
31 #include <itksys/SystemInformation.hxx>
32 #include "itkTimeProbe.h"
33 #include <time.h>
34 
35 
46 void PrintHelp( void );
47 
51 std::string ConvertSecondsToDHMS( const double totalSeconds, const unsigned int precision = 0 )
52 {
54  const std::size_t secondsPerMinute = 60;
55  const std::size_t secondsPerHour = 60 * secondsPerMinute;
56  const std::size_t secondsPerDay = 24 * secondsPerHour;
57 
59  std::size_t iSeconds = static_cast<std::size_t>( totalSeconds );
60  const std::size_t days = iSeconds / secondsPerDay;
61 
62  iSeconds %= secondsPerDay;
63  const std::size_t hours = iSeconds / secondsPerHour;
64 
65  iSeconds %= secondsPerHour;
66  const std::size_t minutes = iSeconds / secondsPerMinute;
67 
68  //iSeconds %= secondsPerMinute;
69  //const std::size_t seconds = iSeconds;
70  const double dSeconds = fmod( totalSeconds, 60.0 );
71 
73  bool nonzero = false;
74  std::ostringstream make_string( "" );
75  if( days != 0 ){ make_string << days << "d"; nonzero = true; }
76  if( hours != 0 || nonzero ){ make_string << hours << "h"; nonzero = true; }
77  if( minutes != 0 || nonzero ){ make_string << minutes << "m"; nonzero = true; }
78  make_string << std::showpoint << std::fixed << std::setprecision( precision );
79  make_string << dSeconds << "s";
80 
82  return make_string.str();
83 
84 } // end ConvertSecondsToDHMS()
85 
86 
88 std::string GetCurrentDateAndTime( void )
89 {
90  // Obtain current time
91  time_t rawtime = time( NULL );
92  // Convert to local time
93  struct tm * timeinfo = localtime( &rawtime );
94  // Convert to human-readable format
95  std::string timeAsString = std::string( asctime( timeinfo ) );
96  // Erase newline character at end
97  timeAsString.erase( timeAsString.end() - 1 );
98  //timeAsString.pop_back() // c++11 feature
99 
100  return timeAsString;
101 } // end GetCurrentDateAndTime()
102 
103 #endif
std::string GetCurrentDateAndTime(void)
Definition: elastix.h:88
std::string ConvertSecondsToDHMS(const double totalSeconds, const unsigned int precision=0)
Definition: elastix.h:51
void PrintHelp(void)


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo