18 #ifndef __MILXGLOBAL_H 19 #define __MILXGLOBAL_H 30 #include <vnl/vnl_vector_fixed.h> 32 #include <itkCommand.h> 37 #include <vtkVersion.h> 38 #include <vtkSmartPointer.h> 39 #include <vtkCommand.h> 40 #include <vtkObject.h> 44 #define WIN32_LEAN_AND_MEAN 59 const float Version =
static_cast<float>(1.0);
60 static bool VerboseMode =
true;
63 typedef double coordinateType;
65 typedef unsigned vnl_size_t;
66 typedef vnl_vector_fixed<coordinateType,3> coordinate;
69 typedef coordinateType* coordinate;
71 const unsigned imgDimension = 3;
76 inline void Swap(T &a, T&b) {
84 inline T Minimum(
const T &a,
const T &b) {
85 return (a < b) ? a : b;
90 inline T Maximum(
const T &a,
const T &b) {
91 return (a > b) ? a : b;
114 std::ostringstream toString;
115 if (!(toString << std::setw(zeroPad) << std::setfill(
'0') << num))
117 return toString.str();
130 GetSystemInfo( &sysinfo );
132 cores = sysinfo.dwNumberOfProcessors;
134 cores = sysconf( _SC_NPROCESSORS_ONLN );
153 for (
size_t i = 0; i < 50; i++)
155 if ( i < (percent/2))
156 bar.replace(i,1,
"=");
157 else if ( i == (percent/2))
158 bar.replace(i,1,
">");
160 bar.replace(i,1,
" ");
163 std::cout<<
"\r" "[" << bar <<
"] ";
164 std::cout.width( 3 );
165 std::cout<< percent <<
"% " << std::flush;
167 std::cout << std::endl;
176 std::cout << msg << std::endl;
185 std::cout <<
"Warning: " << msg << std::endl;
195 std::cerr <<
"Debug: " << msg << std::endl;
204 std::cerr << msg << std::endl;
208 #if defined(SMILI_DLL) 214 #if defined(SMILI_MAKEDLL) // create a SMILI DLL library 215 #define SMILI_EXPORT __declspec(dllexport) 216 #else // use a SMILI DLL library 217 #define SMILI_EXPORT __declspec(dllimport) 240 #ifndef VTK_ONLY //Requires VTK and ITK 270 inline vtkObject* GetUpdateObject()
271 {
return Filter.GetPointer(); }
275 { Filter = vtkSmartPointer<vtkObject>::New(); }
281 inline void Execute(Object *caller,
const EventObject & event)
282 { Execute( (
const Object *)caller, event); }
284 inline void Execute(
const Object *
object,
const EventObject & event)
285 { Filter->InvokeEvent(vtkCommand::ProgressEvent); }
296 #ifndef ITK_ONLY //Requires VTK 324 inline vtkObject* GetUpdateObject()
325 {
return Filter.GetPointer(); }
327 inline bool IsBeingObserved(
unsigned long event = vtkCommand::ProgressEvent)
328 {
return Filter->HasObserver(event); }
332 { Filter = vtkSmartPointer<vtkObject>::New(); }
338 inline void Execute(vtkObject *caller,
unsigned long observedType,
void* message)
339 { Filter->InvokeEvent(vtkCommand::ProgressEvent); }
344 static vtkSmartPointer<vtkProgressUpdates> VTKProgressUpdates = vtkSmartPointer<vtkProgressUpdates>::New();
363 inline const char* GetMessage()
364 {
return m_Message.c_str(); }
366 inline bool HasFailed()
367 {
return m_ErrorEncountered; }
369 inline bool ReportsFailure()
370 {
return m_ErrorEncountered; }
372 inline void Initialize()
373 { m_ErrorEncountered = m_WarningEncountered =
false; }
380 bool m_ErrorEncountered;
381 bool m_WarningEncountered;
382 std::string m_Message;
385 void Execute(vtkObject *caller,
unsigned long observedType,
void* message)
387 m_Message = (
const char*) message;
389 if(observedType == vtkCommand::ErrorEvent)
390 m_ErrorEncountered =
true;
391 if(observedType == vtkCommand::WarningEvent)
392 m_WarningEncountered =
true;
398 #endif //__MILXGLOBAL_H void PrintDebug(const std::string msg)
Displays a generic msg to standard error with carriage return if in Debug mode.
Object for intercepting progress events triggered by ITK based filters and converting them to VTK pro...
Object for intercepting progress events triggered by VTK based filters.
void PrintProgressBar(const size_t percent)
Displays a generic terminal-based progress bar based on the percent provided.
Exception Handler for stringify function. Thrown if the conversion from numeric to string is unsucces...
static vtkErrorWarning * New()
Standard VTK Object Factory.
void PrintError(const std::string msg)
Displays a generic msg to standard error with carriage return.
Object for intercepting errors thrown by VTK based readers.
vtkSmartPointer< vtkObject > Filter
Dummy object for passing on events.
#define SMILI_EXPORT
DLL Function Symbol for Windows. It is empty for other OSes.
void PrintWarning(const std::string msg)
Displays a generic msg to standard output with carriage return.
static ProgressUpdates * New()
Standard ITK Object Factory.
void PrintInfo(const std::string msg)
Displays a generic msg to standard output with carriage return.
std::string NumberToString(double num, unsigned zeroPad=0)
Number to string converter.
vtkSmartPointer< vtkObject > Filter
Dummy object for passing on events.
static vtkProgressUpdates * New()
Standard VTK Object Factory.
unsigned NumberOfProcessors()
Number of processors or cores on the machine.